These exercises cover the sections of Plotting in R PlottingInR.
Please load the dateset subset_GoT from "Got_dataset/subset_GoT.csv"
and use ggplot2 to
create a bar plot using subset_GoT$social_status
and see the number of characters that are Highborn or Lowborn. We will plot this data for the rest of the questions in this section.
assign colours according to whether the characters switched their allegiance (subset_GoT$allegiance_switched
)
add argument position=position_dodge()
in the geom_bar()
function and see what effect this has
use the facet_wrap()
function to separate the figure according to the character’s sex
use the facet_grid()
function to separate the figure according to the character’s sex and occupation
use the facet_wrap()
function to separate the figure according to the character’s sex and occupation, and compare the difference from your answer to (4)
save the final figure as “pdf” file
[hint: use read.csv()
function to load Got_dataset/subset_GoT.csv
]
subset_GoT<-read.csv(file="Got_dataset/subset_GoT.csv")
head(subset_GoT)