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

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ansible warning on jinja2 braces on when -