[R] Quantiles of a subset of data

Pete Brecknock Peter.Brecknock at bp.com
Tue Feb 19 17:36:36 CET 2013


bradleyd wrote
> Thanks for your help Pete. I can almost get it to work with;
> 
>> by(day,year,quantile)
> 
> but this only gives me  0%  25%  50%  75% 100%, not the ones I'm looking
> for, 10% and 90%.
> 
> I have tried;
> 
>> by(day,year,quantile(c(0.1, 0.9))) but this is rejected by
> Error in FUN(X[[1L]], ...) : could not find function "FUN"

Need to add the quantiles of interest .....

# Dummy Data
d <- data.frame(year=c(rep(2010,10),rep(2011,10),rep(2012,10)), quantity =
c(1:30)) 

# Quantiles by Year
by(d$quantity,d$year,quantile,c(0.1,0.9))

HTH

Pete



--
View this message in context: http://r.789695.n4.nabble.com/Quantiles-of-a-subset-of-data-tp4659063p4659072.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list