I need to find the “highest bin for 90% of samples”.
I have a table like this:
my_table <- data.frame(matrix(c(122,68,2,0,30,0,0,0,5,79,23,9000), byrow=TRUE, ncol=4))
names(my_table) <- c("0-10","11-20","21-30","31-5000")
Where the bin-headers indicate minutes (time).
For the first row, 90% of samples are at intervals lower or equal to “11-20”. I.e. 90% of samples have shorter time than 21 minutes.
For second row it is lower or equal to interval “0-10”.
And for third row it is lower or equal to interval “31-5000”.
I would like to add a column “90p-interval” where the above intervals are found automatically, resulting in the table like this:
my_table$Perc90 <- c("11-20","0-10","31-5000")
My real table is thousands and thousands of rows long.
If someone can help I’m very grateful, and also thanks to everyone contributing to this fantastic site!
/Chris
1 Answer