I work with a large number of data(n=2057) and my data frame looks like:
id_num Gender Protein_Milk Protein_Cheese
1 2345 1 4.5 3.4
2 45983 2 5.6 5.2
. . . . .
. . . . .
. . . . .
2057 13454 1 2.6 8.5
I want to create a barplot has both columns Protein_Milk and Protein_Cheese side by side on the x axis grouped by gender. Y axis shows the mean value of Protein(g). The problem is, that I can not create barplot has both columns in it. So I have 2 different barplots for each column (Protein_Milk/Protein_Cheese).
My R-command:
Data_Frame$Gemder<-factor(Data_Frame$Gender, levels = c(1,2), labels = c("Men", "Women"))
Barplot<-ggplot(Data_Frame, aes(Gender, Protein_Milk))
Barplot +
stat_summary(fun.y = mean, geom = "bar")+
stat_summary(fun.data = mean_cl_normal, geom = "errorbar")
Anybody has any suggestions? Thanks in advance
Edit: Since my data is large, I can't use the solution here:
Creating grouped bar-plot of multi-column data in R
I need to find a way how to create barplot with two column, without writing all entries in c() or read.table(text=" ") since it would take so long for 2057 entries per column.