Displaying 1 result from an estimated 1 matches for "myecdf2".
2011 Mar 10
1
getting percentiles by factor
...lt;- 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:
myecdf2 <- function(x, column, sortAsc=True) {
# x data.frame/list being analysed
# column to calculate percentiles on
# sortAsc sorting order (True Ascending, False Descending)
w1 <- ecdf(x$column)
w2 <- if (sortAsc) w1(x$column) * 100 else abs(w1(x$column) * 100 - 100)
w3 <- transform(x, myPe...