title: bar plot 3 categorical variables by continuous variable in R ggplot2
body: <p>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: <a href="https://www.r-bloggers.com/how-to-plot-three-categorical-variables-and-one-continuous-variable-using-ggplot2/" rel="nofollow noreferrer">https://www.r-bloggers.com/how-to-plot-three-categorical-variables-and-one-continuous-variable-using-ggplot2/</a>. 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 </p>
  
  <p>I tried variations of the code above but couldn’t make it work. The answer to <a href="https://stackoverflow.com/questions/31173931/point-plot-with-se-for-3-categorical-1-continuous-variable-in-r">Point Plot with SE for 3 Categorical &amp; 1 Continuous Variable in R</a> 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.</p>
  
  <pre><code>&gt; 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")
  
  &gt; 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")
  </code></pre>