Created
July 24, 2015 12:05
-
-
Save drjwbaker/a4257d6a231adf8bf5a2 to your computer and use it in GitHub Desktop.
(Figure 9) Code, control, and making the argument in the Humanities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#loadpackages | |
setwd("/home/james/Documents/2015-07_BM-R/derived_data") | |
library(lubridate) | |
library(dplyr, warn.conflicts = FALSE) | |
library(tidyr, warn.conflicts = FALSE) | |
library(ggplot2) | |
#read data from csv | |
names <- read.csv("BM.csv") %>% | |
group_by(DECADE, GENDER) %>% | |
mutate(mean_decade = mean(N)) %>% | |
select(mean_decade, DECADE) | |
#plot data | |
ggplot(names, aes(x = (DECADE+5), y = mean_decade, group = GENDER, fill = GENDER)) + | |
ggtitle("A Facet Grid (mean(N), by GENDER)") + | |
geom_bar(stat = "identity") + | |
facet_grid(GENDER ~ .) + | |
coord_flip() | |
#save data to file | |
setwd("/home/james/Documents/2015-07_BM-R/viz") | |
ggsave("BM_decade-mean-bargrid.png", width = 7, height = 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment