I have grouped data in this format Size -- Count 0-10 -- 15 10-20 -- 25 20-50 -- 10 50-100 -- 5 I've been trying to find a way to set this up with the proper histogram heights, but can't seem to figure it out. So any help would be much appreciated! -- View this message in context: http://www.nabble.com/Histogram-for-grouped-data-in-R-tp21624806p21624806.html Sent from the R help mailing list archive at Nabble.com.
Hi,
Try this:
x<-c(15,25,10,5)
names(x)<-c('0-10','10-20','20-50','50-100')
barplot(x,space=0,xlab='Size',ylab='Count',col=1:4)
See ?barplot for more information.
HTH,
Jorge
On Fri, Jan 23, 2009 at 8:55 AM, darthgervais <darthgervais@yahoo.ca>
wrote:
>
> I have grouped data in this format
>
> Size -- Count
> 0-10 -- 15
> 10-20 -- 25
> 20-50 -- 10
> 50-100 -- 5
>
> I've been trying to find a way to set this up with the proper histogram
> heights, but can't seem to figure it out. So any help would be much
> appreciated!
> --
> View this message in context:
>
http://www.nabble.com/Histogram-for-grouped-data-in-R-tp21624806p21624806.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
Le ven. 23 janv. ? 08:55, darthgervais a ?crit :> > I have grouped data in this format > > Size -- Count > 0-10 -- 15 > 10-20 -- 25 > 20-50 -- 10 > 50-100 -- 5 > > I've been trying to find a way to set this up with the proper > histogram > heights, but can't seem to figure it out. So any help would be much > appreciated!Define your data as a "grouped.data" object using the function of the same name in package actuar. Then you can simply use hist() as usual to get what you want. See: @Article{Rnews:Goulet+Pigeon:2008, author = {Vincent Goulet and Mathieu Pigeon}, title = {Statistical Modeling of Loss Distributions Using actuar}, journal = {R News}, year = 2008, volume = 8, number = 1, pages = {34--40}, month = {May}, url = http, pdf = Rnews2008-1 } HTH --- Vincent Goulet Acting Chair, Associate Professor ?cole d'actuariat Universit? Laval, Qu?bec Vincent.Goulet at act.ulaval.ca http://vgoulet.act.ulaval.ca
The category widths are not equal. Surely, what you mean is:
x <- c(15,25,rep(10/3,3),rep(5/5, 5))
names(x) <-
c('0-10','10-20','','20-50',rep('',3),
'50-100', '', '')
barplot(x,space=0, xlab='Size', ylab='Count', border = NA,
col=c(1,2, rep(3,3), rep(4,5)))
:-)
Jon Anson
Jorge Ivan Velez wrote:
Hi,
Try this:
x<-c(15,25,10,5)
names(x)<-c('0-10','10-20','20-50','50-100')
barplot(x,space=0,xlab='Size',ylab='Count',col=1:4)
See ?barplot for more information.
HTH,
Jorge
On Fri, Jan 23, 2009 at 8:55 AM, darthgervais <darthgervais at yahoo.ca>
wrote:
> >
> > I have grouped data in this format
> >
> > Size -- Count
> > 0-10 -- 15
> > 10-20 -- 25
> > 20-50 -- 10
> > 50-100 -- 5
> >
> > I've been trying to find a way to set this up with the proper
histogram
> > heights, but can't seem to figure it out. So any help would be
much
> > appreciated!
> > --
> > View this message in context:
> >
http://www.nabble.com/Histogram-for-grouped-data-in-R-tp21624806p21624806.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
[[alternative HTML version deleted]]
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
--
Yonathan (Jon) Anson
Dept.of Social Work
Ben Gurion University of the Negev
84105 Beer Sheva, Israel.
Tel: +972-8-6479314 (w) +972-8-6489286 (h) 054-7233279 (m)
Fax: +972-8-647 9233
Ok, use library agricolae, graph.freq() is similar hist(), aditional parameters size<- c(0,10,20,50,100) f<-c(15,25,10,5) library(agricolae) h<-graph.freq(size,counts=f,axes=F) axis(1,x) axis(2,seq(0,30,5)) Other function: # is necesary histogram h with hist() or graph.freq() h<-graph.freq(x,counts=f,axes=F) axis(1,x) normal.freq(h,col="red") table.freq(h) ojiva.freq(h,type="b",col="blue") Regards, Felipe de Mendiburu http://tarwi.lamolina.edu.pe/~fmendiburu ________________________________ From: r-help-bounces at r-project.org on behalf of darthgervais Sent: Fri 1/23/2009 8:55 AM To: r-help at r-project.org Subject: [R] Histogram for grouped data in R I have grouped data in this format Size -- Count 0-10 -- 15 10-20 -- 25 20-50 -- 10 50-100 -- 5 I've been trying to find a way to set this up with the proper histogram heights, but can't seem to figure it out. So any help would be much appreciated! -- View this message in context: http://www.nabble.com/Histogram-for-grouped-data-in-R-tp21624806p21624806.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.