1

Possible Duplicate:
geom_boxplot with precomputed values

I am wondering how to convert a frequency table like following to boxplot by ggplot2 to show distribution of each Group(Group as x axis and Frequency as y axis). It stuck me for a while since boxplot examples I found by google, y axis values are all need to be given by each data point, not frequency.

    Group1  Group2  …   Group60
1-100   8   5       15
101-200 12  7       21
201-300 15  11      33
301-400 25  12      35
401-500 40  15      45
501-600 43  18      55
…               


data=read.table(file="data.csv",sep=",",header=TRUE,row.names=1)
df=melt(data)
df$variable=factor(df$variable)
names(df)=c("Group","freq")

then ?

Community
  • 1
  • 1
user1269298
  • 717
  • 2
  • 8
  • 26
  • 1
    Are you sure you don't mean a bar chart, or possibly a histogram? If so, for pre-computed values you generally want to use `stat = "identity"`. – joran Jun 27 '12 at 20:54
  • 1
    I think @joran got it right, but if you really meant boxplot, see [this post](http://stackoverflow.com/questions/10628847/geom-boxplot-with-precomputed-values?rq=1) for a potential solution. – Justin Jun 27 '12 at 21:14
  • 1
    Also, please avoid cross posting. Many of the people on the ggplot2 mailing list also are regulars here on SO. Pick one, and if after several days you don't get a good answer, try the other. – joran Jun 27 '12 at 23:34
  • @Justin thanks for the solution, the way convert the data to quantile then plot it can exactly solve my problem! – user1269298 Jun 29 '12 at 02:04
  • @joran Yes, stat = "identity", thanks for the hint! – user1269298 Jun 29 '12 at 02:05

0 Answers0