[R] Add a column to a data frame with value based on the percentile of the row

Dark info at software-solutions.nl
Wed Jul 31 14:49:15 CEST 2013


Hi Arun Kirshna,

I have tested your method and it will work for me.
I only run into one problem. Before I want to do this operation I have
sorted my data frame so my rownumbers ar not subsequent.

You can see if you first order your example data frame like:
dat1 <- dat1[order(-dat1$value),]

head(dat1)
     ID    value   SEGMENT
237 237 3.538552  20 to 50
21   21 3.376149    Top 5%
421 421 3.015634 Bottom 50
339 339 2.855991 Bottom 50
119 119 2.589574  20 to 50
12   12 2.512276    Top 5%

Do you have a solution for this?





--
View this message in context: http://r.789695.n4.nabble.com/Add-a-column-to-a-data-frame-with-value-based-on-the-percentile-of-the-row-tp4672711p4672726.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list