Displaying 1 result from an estimated 1 matches for "myexampleend".
2011 Mar 10
1
getting percentiles by factor
...t(myExample)
Thanks to Patrick I I managed to put together the following lines which does
it for the "Ret" column:
myecdf <- function(x, sortAsc) {
w1 <- ecdf(x$Ret)
w2 <- if (sortAsc) w1(x$Ret) * 100 else abs(w1(x$Ret) * 100 - 100)
w3 <- transform(x, myPerc=w2)
return(w3)
}
myExampleEnd <- lapply(split(myExample, myExample$Sectors), myecdf,
sortAsc="True")
myExampleEnd <- unsplit(myExampleEnd, myExample$Sectors)
I need to make the function more flexible accepting the name of the column
to calculate percentiles on as a parameter but the following doesn't work:...