[R] quantile / centile

Henrique Dallazuanna wwwhsd at gmail.com
Sat Sep 27 14:54:44 CEST 2008


Try this:

my.df$my.newvar <- quantile(my.df$my.var, probs = seq(0.01,1, 0.01))


On Sat, Sep 27, 2008 at 3:50 AM, Donald Braman <dbraman at law.gwu.edu> wrote:
> I'm wondering if there is a simple way to assign a quantile to a vector in a
> data frame, much like one could in Stata using centile. Let's say I want 100
> slices in my assignation. I can easily see what the limits of each slice by
> using quantile:
> quantile(my.df$my.var, probs=seq(0, 1, 0.01))
>
> But how do I assign the appropriate value to each row/record in my data
> frame? Clearly the following won't work, but what will?
>
> my.df$my.new.var <- quantile(my.df$my.var, probs=seq(0, 1, 0.01))
>
>        [[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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list