0

I tried to make a boxplot today using ggplot2, and I encountered an error I haven't been able to solve, yet. I have used a similar approach (which I actually took from an answer by user @joran) before without incident, but I must be doing something incorrectly this time.

Here is my data:

myboxplot<-structure(list(gap = structure(1:2, .Label = c("Jib", "NoJib"), class = "factor"), Location = structure(c(4L, 4L), .Label = c("A", "B", "C", "D"), class = "factor"), min = c(21.809, 21.081), q1 = c(25.582, 25.375), med = c(28.082, 27), q3 = c(30.142, 28.622), max = c(37.166, 39.808), lab = c(2342L, 119681L)), .Names = c("JibStat", "Location", "min", "q1", "med", "q3", "max", "lab"), row.names = c(2L, 7L ), class = "data.frame")

The code that I have been attempting to use is as follows:

ggplot(myboxplot + aes(x=JibStat, fill=JibStat)) +
      geom_boxplot(aes(lower = q1, upper = q3, middle = med, ymin = min, ymax = max), stat = "identity")

and I get the following error message:

Error in Ops.data.frame(myboxplot, aes(x = JibStat, fill = JibStat)) : list of length 2 not meaningful

I have worked on resolving the issue, but I have not been able to find much on resolving the error. My Google skills must be lacking today, but I can't think of what to search for to get help on this problem. What is it I am doing wrong here?

Additional info: R version 3.0.1, 64-bit Windows 8.

Community
  • 1
  • 1
Jota
  • 17,281
  • 7
  • 63
  • 93

1 Answers1

2

Try changing the first line to:

ggplot(myboxplot, aes(x=JibStat)) +  
    geom_boxplot(aes(lower = q1, upper = q3, middle = med, 
               ymin = min, ymax = max), stat = "identity")

I think you'd mis-typed a comma.

Didzis Elferts
  • 95,661
  • 14
  • 264
  • 201
will.pearse
  • 234
  • 1
  • 6
  • 1
    Ah, how embarrassing. I worked on resolving the error for longer than I care to admit. – Jota Oct 14 '13 at 19:28