Files corresponding to Short Course: Introduction to Data Science Using R
We’ll continue to work on the same .Rmd file from the previous exercise.
names <- c("Justin", "George", "Alexander", "Jacob", "Anderson")
barData <- BabyNamesFull %>%
filter(name %in% names) %>%
group_by(name) %>%
summarise(total = sum(count))
geom_bar()
function.ggplot(barData) +
geom_bar(stat = "identity", aes(x = name, y = total))
barDataSex <- BabyNamesFull %>%
filter(name %in% c("Shannon", "Lindsay", "Avery")) %>%
group_by(name, sex) %>%
summarise(total = sum(count))
## `summarise()` has grouped output by 'name'. You can override using the `.groups` argument.
ggplot(barDataSex) +
geom_bar(stat = "identity", aes(x = name, y = total, fill = sex))