Hi
r-help-boun...@r-project.org napsal dne 22.09.2009 11:51:18: > > Hi,everyone i need to calculate quartile values of a variable grouped by the > other variable . > same as in aggregate function(only median,mean or functions is possible-i > think so) > Could you please help me to achieve the same for other quartile > values(5,10,25,75,90) as for median using aggregate. > Thanks in advance. > data : > zip price > 60000 567000 > 60001 478654 > 60004 485647 > 60001 2783958 > 60005 97845848 > 60006 378383478 > 60002 397895735 > 60001 487587575 > 60002 478848 > 60003 49847874 > 60004 467648 > 60005 567489 > 60006 4776746 > 60004 4843949 > what i want i quartile values of price grouped by zip If you need several values of quantiles together aggregate is not suitable as the function needs to return scalar aggregate(rnorm(60), list(sample(1:5,60, replace=T)), function(x) quantile(x,c(.05,.5,.95))) Error in aggregate.data.frame(as.data.frame(x), ...) : 'FUN' must always return a scalar but you can use by by(rnorm(60), list(sample(1:5,60, replace=T)), function(x) quantile(x,c(.05,.5,.95))) or some other aggregating functions e.g. in doBy or plyr packages or to use split/sapply construct. Regards Petr > -- > View this message in context: http://www.nabble.com/use-of-class-variable-in- > r-as-in-Proc-means-of-sas-tp25530654p25530654.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. ______________________________________________ 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.