[R] Percentile rank for each element in list
Hlp Given this data x - c(1,5,100,300,250,200,550,900,1000) quantile(x) 0% 25% 50% 75% 100% 1 100 250 550 1000 When I run the quantile, I can only know the value of the nth percentile I want to know what's the percentile position of each items in the list Sample 1 = 100% on the list has 1 or more 5 = more than x% on the list has 5 or more 100 = more than x% on the list has 100 or more 250 = more than 50% on the list has 250 or more etc Thanks in advance __ 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.
Re: [R] Percentile rank for each element in list
Hi, I think you want ecdf(), but read the help page because it works a little different than you might expect. ecdf.x - ecdf(x) ecdf.x(x) Best, Ista On Tue, Sep 7, 2010 at 8:37 AM, mic mikezia...@gmail.com wrote: Hlp Given this data x - c(1,5,100,300,250,200,550,900,1000) quantile(x) 0% 25% 50% 75% 100% 1 100 250 550 1000 When I run the quantile, I can only know the value of the nth percentile I want to know what's the percentile position of each items in the list Sample 1 = 100% on the list has 1 or more 5 = more than x% on the list has 5 or more 100 = more than x% on the list has 100 or more 250 = more than 50% on the list has 250 or more etc Thanks in advance __ 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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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.
Re: [R] Percentile rank for each element in list
Is this what you want to have: x - c(1,5,100,300,250,200,550,900,1000) # assume you want the position of 25th percentile which(x==quantile(x,0.25)) [1] 3 Note that position is meaningful only when the percentile is one of the observed data values. If you want to know the position of 70th percentile (that is between position 6 and position 7). You need to do something coding to get these two adjacent positions. -- View this message in context: http://r.789695.n4.nabble.com/Percentile-rank-for-each-element-in-list-tp2529523p2529741.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.
Re: [R] Percentile rank for each element in list
Otherwise you can try following: x - c(1,5,100,300,250,200,550,900,1000) which(x==quantile(x,0.25,type=3)) This will always return number within your vector. See further information with ?'quantile' Thanks and regards, -- View this message in context: http://r.789695.n4.nabble.com/Percentile-rank-for-each-element-in-list-tp2529523p2530029.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.
Re: [R] Percentile rank for each element in list
It seems to produce some strange values: xx=1:10 which(xx==quantile(x,0.2,type=3)) [1] 5 which(xx==quantile(x,0.5,type=3)) integer(0) -- View this message in context: http://r.789695.n4.nabble.com/Percentile-rank-for-each-element-in-list-tp2529523p2530060.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.