Mary Kindall
2012-Jan-12 17:02 UTC
[R] relative frequency plot using ggplot or other function
Hi I have a data frame in the following form. There are two groups and for each 'width' relative frequency for group1 and group2 is given. How to plot this in R using ggplot or other package. Width relativeFrequency1 relativeFrequency2 1 100 0.0006388783 0.02265428 2 200 0.0022677303 0.02948625 3 300 0.0061182673 0.01739936 4 400 0.0152237225 0.02569902 5 500 0.0300215262 0.03639880 6 600 0.0597610250 0.07717765 Thanks -- ------------- Mary Kindall Yorktown Heights, NY USA [[alternative HTML version deleted]]
Justin Haynes
2012-Jan-12 17:13 UTC
[R] relative frequency plot using ggplot or other function
On Thu 12 Jan 2012 09:02:27 AM PST, Mary Kindall wrote:> Hi > I have a data frame in the following form. There are two groups and for > each 'width' relative frequency for group1 and group2 is given. How to plot > this in R using ggplot or other package. > > > Width relativeFrequency1 relativeFrequency2 > 1 100 0.0006388783 0.02265428 > 2 200 0.0022677303 0.02948625 > 3 300 0.0061182673 0.01739936 > 4 400 0.0152237225 0.02569902 > 5 500 0.0300215262 0.03639880 > 6 600 0.0597610250 0.07717765 > > > Thanks >not sure exactly what you're looking for but...> dat<-data.frame(width=1:6*100,rel1=runif(6), rel2=runif(6)) > dat.melt<-melt(dat,id.var='width') > ggplot(dat.melt,aes(x=factor(width),y=value,fill=variable))+geom_bar(stat='identity',position='dodge')