search for: chosen_cases

Displaying 1 result from an estimated 1 matches for "chosen_cases".

2002 Jun 06
1
sampling from data frame
...data frame and given a factor variable that assigns a class to each case in the data frame, what is the most efficient way to sample a given number of cases from each class? I've found a roundabout solution that works as follows: for each class: assign unique index to each class member chosen_cases <- sample(n,indexvariable) extract chosen_cases from data frame (i.e. chosen <- subset(data, indexvariable %in% chosen_cases)) this solution relies on the Hmisc library and is horribly inefficient. Any ideas on how to make it better would be greatly appreciated. Best from Edinburgh...