Hi, how can I treat data organised in classes and frequencies? Ex. class frequency 20-23 9 23-25 7 26-28 5 29-31 5 32-34 3 Thanks Angelo Scozzarella
I don´t know what you means by "treat", but may be you want something like my.df<-read.table(stdin(), head=T, sep=",") class,frequency 20-23,9 23-25,7 26-28,5 29-31,5 32-34,3 rownames(my.df)<-my.df$class barplot (my.df$frequency) axis(1, 1:dim(my.df)[1], rownames(my.df)) Cheers, miltinho astronauta brazil On 7/23/08, Angelo Scozzarella <angeloscozzarella@tiscali.it> wrote:> > Hi, > > how can I treat data organised in classes and frequencies? > > Ex. > > class frequency > > 20-23 9 > 23-25 7 > 26-28 5 > 29-31 5 > 32-34 3 > > > > Thanks > > Angelo Scozzarella > > ______________________________________________ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Try this: with(x, barplot(frequency, names.arg = class)) On Wed, Jul 23, 2008 at 3:29 PM, Angelo Scozzarella <angeloscozzarella at tiscali.it> wrote:> Hi, > > how can I treat data organised in classes and frequencies? > > Ex. > > class frequency > > 20-23 9 > 23-25 7 > 26-28 5 > 29-31 5 > 32-34 3 > > > > Thanks > > Angelo Scozzarella > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
Try see doBy package.
Below you have a code on brute force.
kind regards,
miltinho
brazil----
==number.of.records<-20
my.df<-data.frame(v1=sample(21:34,number.of.records, replace=T),
v2=runif(number.of.records), v3=runif(number.of.records))
my.df$v1<-as.numeric(as.character(my.df$v1))
my.df$v2<-as.numeric(as.character(my.df$v2))
my.df$v3<-as.numeric(as.character(my.df$v3))
my.df
## up to here we just created a data.set
my.df$v1.class<-cut(my.df$v1,breaks=c(20,23,26,29,34))
my.df
my.stats<-aggregate(my.df[,c("v2","v3")],
by=list(my.df$v1.class), length)
colnames(my.stats)<-c("v1.classs", "freq_v1",
"freq_v2")
my.stats
my.stats<-cbind(my.stats, aggregate(my.df[,c("v2","v3")],
by=list(my.df$v1.class), mean))
colnames(my.stats)<-c("v1.classs", "freq_v1",
"freq_v2", "rm1", "mean_v1",
"mean_v2")
my.stats
my.stats<-cbind(my.stats, aggregate(my.df[,c("v2","v3")],
by=list(my.df$v1.class), median))
colnames(my.stats)<-c("v1.classs", "freq_v1",
"freq_v2", "rm1", "mean_v1",
"mean_v2",
"rm2", "median_v1", "median_v2")
my.stats
On 7/23/08, Angelo Scozzarella <angeloscozzarella@tiscali.it>
wrote:>
> Thanks, but I want to calculate index like mean, median .....
>
>
> How can I do it?
>
>
> Angelo Scozzarella
>
>
>
> Il giorno 23/lug/08, alle ore 20:46, milton ruser ha scritto:
>
> I don´t know what you means by "treat", but may be you want
something
> like
> my.df<-read.table(stdin(), head=T, sep=",")
> class,frequency
> 20-23,9
> 23-25,7
> 26-28,5
> 29-31,5
> 32-34,3
>
> rownames(my.df)<-my.df$class
> barplot (my.df$frequency)
> axis(1, 1:dim(my.df)[1], rownames(my.df))
>
> Cheers,
> miltinho astronauta
> brazil
>
>
>
> On 7/23/08, Angelo Scozzarella <angeloscozzarella@tiscali.it> wrote:
>>
>> Hi,
>>
>> how can I treat data organised in classes and frequencies?
>>
>> Ex.
>>
>> class frequency
>>
>> 20-23 9
>> 23-25 7
>> 26-28 5
>> 29-31 5
>> 32-34 3
>>
>>
>>
>> Thanks
>>
>> Angelo Scozzarella
>>
>> ______________________________________________
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
>
[[alternative HTML version deleted]]
Hi Angelo, Look carefully at package vcd; and at log-linear models (+ glm(..., family=poisson)). For overdispersion there are more advanced methods. HTH, Mark. Angelo Scozzarella wrote:> > Hi, > > how can I treat data organised in classes and frequencies? > > Ex. > > class frequency > > 20-23 9 > 23-25 7 > 26-28 5 > 29-31 5 > 32-34 3 > > > > Thanks > > Angelo Scozzarella > > ______________________________________________ > 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. > >-- View this message in context: http://www.nabble.com/Histogram-tp18617432p18619628.html Sent from the R help mailing list archive at Nabble.com.
Le mer. 23 juil. ? 14:29, Angelo Scozzarella a ?crit :> Hi, > > how can I treat data organised in classes and frequencies? > > Ex. > > class frequency > > 20-23 9 > 23-25 7 > 26-28 5 > 29-31 5 > 32-34 3It depends what you mean by "treat", but package actuar has a function grouped.data() to create such objects. Then, there are methods to compute the mean or plot the histogram. See the "lossdist" package vignette for details. HTH Vincent -- Vincent Goulet, Associate Professor ?cole d'actuariat Universit? Laval, Qu?bec Vincent.Goulet at act.ulaval.ca http://vgoulet.act.ulaval.ca> Thanks > > Angelo Scozzarella