Re: [R] Histogram

From: milton ruser <milton.ruser_at_gmail.com>
Date: Wed, 23 Jul 2008 16:49:29 -0300

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_at_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_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<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. Received on Wed 23 Jul 2008 - 20:41:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 21:32:54 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive