I’m trying to plot a barplot with 3 categoricals by one continuous variable. It’s easy to do in an excel or google spreadsheet, but the ggplot2 code is a bit hard. I tried modifying this but couldn't get it to work: https://www.r-bloggers.com/how-to-plot-three-categorical-variables-and-one-continuous-variable-using-ggplot2/. What I need is the y axis data (V) grouped by two time periods (0, 60) for one categorical group (NW, OB) and another (M,F) so you have four bars in two groups (by gender and by body weight). I’m using the mean values of V for each group rather than the whole dataset. The values are V0M 1.680 V0F 1.59 V60M 1.673, V60F 1.479, V0NW 1.679, V60NW 1.69 V0OB 1.613, V60OB 1.507
I tried variations of the code above but couldn’t make it work. The answer to Point Plot with SE for 3 Categorical & 1 Continuous Variable in R looks like it would work with the full dataset but I’ll have create another grouping equivalent to the “mea” variable, I think. The error bars would be nice but not essential. Can this be done in ggplot2 with only the means? Thanks in advance.
> dput(A0068tinyhead)
structure(list(A = c("", "", "1", "2", "3", "4"), B = c("", "gender",
"F", "F", "F", "F"), C = c("", "b", "normal", "normal", "normal",
"normal"), D = c("", "V0", "1.4", "1.98", "1.98", "1.91"), E = c("",
"V0NW", "1.4", "1.98", "1.98", "1.91"), F = c("", "VOOB", "1.84",
"1.75", "1.12", "1.75"), G = c("", "V0F", "1.4", "1.98", "1.98",
"1.91"), H = c("", "V0M", "1.75", "1.45", "1.47", "1.86"), I = c("",
"V60", "1.6", "1.77", "1.89", "1.63"), J = c("", "V60NW", "1.6",
"1.77", "1.89", "1.63"), K = c("", "V60OB", "1.8", "1.51", "1.22",
"1.1"), L = c("", "V60F", "1.6", "1.77", "1.89", "1.63"), M = c("",
"V60M", "1.5", "1.73", "1.82", "1.55")), .Names = c("A", "B",
"C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"), row.names = c(NA,
6L), class = "data.frame")
> dput(A0068tinytail)
structure(list(A = c("45", "46", "47", "48", "49", "50"), B = c("M",
"M", "M", "M", "M", "M"), C = c("obese", "obese", "obese", "obese",
"obese", "obese"), D = c("1.57", "1.81", "1.91", "1.69", "1.59",
"1.78"), E = c("", "", "", "", "", ""), F = c("", "", "", "",
"", ""), G = c("", "", "", "", "", ""), H = c("", "", "", "",
"", ""), I = c("1.54", "1.63", "1.53", "1.54", "1.67", "1.5"),
J = c("", "", "", "", "", ""), K = c("", "", "", "", "",
""), L = c("", "", "", "", "", ""), M = c("", "", "", "",
"", "")), .Names = c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M"), row.names = 47:52, class = "data.frame")