dear Vincy,
Firstly, a suggestion: to increase the probability of getting help, you
should provide reproducible code (people can do "copy-and-paste" of your
code and to modify the code to obtain the response.. )
However a possible solution (not tested, of course..) could be simply
a<-tapply(rate, rating, mean)
d<-data.frame(rating=names(a),mean=a)
best,
vito
Il 27/10/2010 12.39, Vincy Pyne ha scritto:
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.
--
====================================
Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 23895240
fax: 091 485726/485612
http://dssm.unipa.it/vmuggeo
______________________________________________
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.