Dear Sirs,

Thanks a lot for your great help. This is going to help me immensely in future as many times I had found myself struggling with this problem. 

Thanks again for the great help.

Regards

Vincy



--- On Wed, 10/27/10, Dimitri Liakhovitski <dimitri.liakhovitski@gmail.com> wrote:

From: Dimitri Liakhovitski <dimitri.liakhovitski@gmail.com>
Subject: Re: [R] One silly question about "tapply output"
To: "Vincy Pyne" <vincy_pyne@yahoo.ca>
Received: Wednesday, October 27, 2010, 11:28
 AM

Assign your result to an object and then write out the object as a csv
file. For example:

x<-data.frame(rating=rep(letters[1:3],2),rate=runif(1:6)) # example data frame
rating.means<-tapply(x$rate,x$rating,mean)
write.csv(rating.means,file="my.file.csv",row.names=T)

Dimitri

On Wed, Oct 27, 2010 at
 6:39 AM, Vincy Pyne <vincy_pyne@yahoo.ca> wrote:
> Dear R helpers
>
> I have a data which gives Month-wise and Rating-wise Rates. So the input file is something like
>
> month           rating           rate
> January        AAA             9.04
> February      AAA             9.07
> ..........................................
> ..........................................
> Decemeber     AAA            8.97
> January          
 BBB           11.15
> February         BBB            11.13
>
>
>
> January          CCC            17.13
> .............................................
> ............................................
> December       CCC           17.56
>
> and so on.
>
> My objective is to calculate Rating-wise mean rate, for which I have used
>
> rating_mean = tapply(rate, rating, mean)
>
> and I am getting following output
>
>> tapply(rate, rating, mean)
>       AAA          
 BBB                      CCC
>        9.1104       11.1361637            17.1606779
>
> which is correct when compared with an excel output.
>
> However, I wish to have my output something like a data.frame (so that I should be able to save this output as csv file with respective headings and should be able to carry out further analysis)
>
> Rating         Mean
> AAA            9.1104
> BBB           11.1361637
> CCC           17.1606779
>
>
> Please guide as how should
 I achieve my output like this.
>
> Thanking in advance.
>
> Regards
>
> Vincy
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>
>



-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com



	[[alternative HTML version deleted]]

