r - Subset dataset to 99.5th percentile for each of a categorical variable -


i want subset data.frame keep 99.5th percentile of each of categorical variable.

my data has minutes used = minutes , location = location

i take out top .5 percent of minutes data each location.

the new subset have 99.5 percentile of location 1. 99.5 percentile of location 2, etc.

thank you!

this solve problem although it'd helpful if post data.

library(plyr)  #add column information on 99.5% cutoff new.dataset1 <- ddply(your.dataset, "location", mutate, minutes.99.5.cutoff =                                                quantile(minutes.used, 0.95))   #subset data include bottom 99.5% of data,  #select first 2 columns trimmed.dataset <- new.dataset1[which(new.dataset1$minutes.used <=                                        new.dataset1$minutes.99.5.cutoff),1:2] 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -