-1

I have a data file with 4 columns. but the number of rows for each column is different. I want to make a box plot using a command like this:

ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() + stat_summary(fun.y=mean, colour="darkred", geom="point",
                              shape=18, size=3,show_guide = FALSE)

but due diffent number of rows per column, it gives error. do you guys know how to that?

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
user3631908
  • 23
  • 1
  • 8

1 Answers1

1

You should bring it to long form with something like reshape or melt. Then it shouldn't be a problem that tehre are a different number of observations for each group.

See this post: Reshaping data.frame from wide to long format with many examples.

Community
  • 1
  • 1
Mario
  • 2,393
  • 2
  • 17
  • 37