Created
September 27, 2017 13:27
-
-
Save PsychBrief/2c6294c4db3f218d8a08c94f2838d566 to your computer and use it in GitHub Desktop.
How the authors in my feed are divided along the lines of gender, race, and whether they are an ECR or not
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
Gender | |
#Create a string called "BlogName" with all the names of the different blogs in it | |
BlogName<-c("Brown", "Coyne", "Allen", "Neurobonkers", "Sakaluk", "Heino", "Kruschke", "Giner-Sorolla", "Magnusson", "Zwaan", "CogTales", "Campbell", "Vanderkerckhove", "Mayo", "Funder", "Schonbrodt", "Fried", "Coyne", "Yarkoni", "Neuroskeptic", "JEPS", "Morey", "PsychBrief", "DataColada", "Innes-Ker", "Schwarzkopf", "PIG-E", "Rousselet", "Gelman", "Bishop", "Srivastava", "Vazire", "Etz", "Bastian", "Zee", "Schimmack", "Hilgard", "Rouder", "Lakens") | |
#Create a vector called "BlogGender" with a string of numbers to represent either female, male, or N/a | |
BlogGender<-c(2,2,2,2,2,2,2,2,2,2,1,1,2,2,1,2,2,2,2,2,2,3,2,1,2,2,2,1,2,2,2,2,1,2,1,2,1,2,2,2,2,2) | |
#Turn BlogGender into a factor where 1 is labelled Female, 2 male, and 3 N/a | |
BlogGender<-factor(BlogGender, levels= c(1:3), labels =c("Female","Male", "N/a")) | |
#Create a data frame of the variable BlogName by the variable BlogGender | |
Blogs<-data.frame(Name=BlogName, Gender=BlogGender) | |
#Because I'm a peasant and can't work out how to create a graph straight from the data frame I created (though #I'm pretty sure I can't in its current form and don't know how to transform it into something that can be #mapped to a graph) I created one vector and one string with the number of male and female blog authors after #counting them up | |
Gender<-c("Female", "Male") | |
Frequency<-c(7,34) | |
#Data frame of the vector and string | |
Blogsdata<-data.frame(Gender,Frequency) | |
#Graph object of the data frame with gender as the x axis and frequency as the y, coloured according to the variable Gender | |
Gender_Graph<-ggplot(Blogsdata, aes(Gender, Frequency, fill=Gender)) | |
#Put bars on my graph object and give it a title | |
Gender_Graph+geom_bar(stat="identity")+ ggtitle("Number of female blog authors compared to male blog authors") | |
Ethnicity | |
BlogName<-c("Brown", "Coyne", "Allen", "Neurobonkers", "Sakaluk", "Heino", "Kruschke", "Giner-Sorolla", "Magnusson", "Zwaan", "CogTales", "Campbell", "Vanderkerckhove", "Mayo", "Funder", "Schonbrodt", "Fried", "Coyne", "Yarkoni", "Neuroskeptic", "JEPS", "Morey", "PsychBrief", "DataColada", "Innes-Ker", "Schwarzkopf", "PIG-E", "Rousselet", "Gelman", "Bishop", "Srivastava", "Vazire", "Etz", "Bastian", "Zee", "Schimmack", "Hilgard", "Rouder", "Lakens") | |
Ethnlist<-c(1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1) | |
BlogEthn<-factor(Ethnlist, levels= c(1:3), labels =c("White","Non-white", "N/a")) | |
Ethn<-c("White", "Non-white") | |
Frequency<-c(39, 2) | |
Ethndata<-data.frame(Ethn,Frequency) | |
EthnGraph<-ggplot(Ethndata, aes(Ethn, Frequency, fill=Ethn)) | |
EthnGraph+geom_bar(stat="identity")+ ggtitle("Number of non-white blog authors compared to white blog authors") | |
ECR | |
BlogName<-c("Brown", "Coyne", "Allen", "Neurobonkers", "Sakaluk", "Heino", "Kruschke", "Giner-Sorolla", "Magnusson", "Zwaan", "CogTales", "Campbell", "Vanderkerckhove", "Mayo", "Funder", "Schonbrodt", "Fried", "Coyne", "Yarkoni", "Neuroskeptic", "JEPS", "Morey", "PsychBrief", "DataColada", "Innes-Ker", "Schwarzkopf", "PIG-E", "Rousselet", "Gelman", "Bishop", "Srivastava", "Vazire", "Etz", "Bastian", "Zee", "Schimmack", "Hilgard", "Rouder", "Lakens") | |
ECRlist<-c(1,2,2,3,1,1,2,2,1,2,1,1,2,2,2,2,2,2,2,2,2,3,2,1,2,2,2,2,2,2,2,2,2,2,2,1,2,1,2,2,2,2) | |
BlogECR<-factor(ECRlist, levels= c(1:3), labels =c("Yes","No", "N/a")) | |
ECR<-c("Yes", "No") | |
Frequency<-c(9, 31) | |
ECRdata<-data.frame(ECR,Frequency) | |
ECRGraph<-ggplot(ECRdata, aes(ECR, Frequency, fill=ECR)) | |
ECRGraph+geom_bar(stat="identity")+ ggtitle("Number of non-ECR blog authors compared to ECR blog authors") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment