Hello, I have got a dataframe which looks like:
y <- c(1,5,6,2,5,10) # response x <- c(2,12,8,1,16,17) # predictor group <- factor(c(1,2,2,3,4,4)) # group df <- data.frame(y,x,group) Now I'd like to resample that dataset. I want to get dataset (row) per group. So per total sample I get 4 rows into a new data frame. How can I do that? Is there any simple approach using an existing package. I looked at function strata() from package sampling. I don't if that is the function for that or if there is a simpler approach with sample(). What I unsuccessfully tried so far: library(sampling) strata(data=df,group,size=(rep(1,nlevels(group)))) Maybe you can help me to do this resampling... Thank you, Johannes -- ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.