First off, thanks for your help if you have any comments, and I apologize if there is a post about this somewhere (I was unable to find one).
So, here is my problem. I need to randomly draw samples from my dataset of grouped data. I have observations in separate rows. Each participant belongs to both of two groups (data drawn at separate times) and has numerous observations (100 or so repeated-measures observations; so each participant has data on about 100 or so rows). I need to randomly draw two observations from each participant within each group. Then I will statistically evaluate those data. Then I will draw four observations from participant from each group. Repeat analysis. Then six, eight, etc. (It's a reliability study).
So, the problem I have is randomly drawing a subsample from among the 100 or so observations of a participant in a group. Does anyone have any idea how I could accomplish this in R. I hope I explained this well; let me know if you need more details.
ddply from the plyr package could make this a relatively easy task. I wasn't sure if you wanted to sample from within each time period within each participant but that's what my code is doing.
Code:
library(plyr)
ddply(testmatrix, .(Participant, Time), summarize, out = sample(AdpMeanAmp, 2))
If you just want the sample to be from the Participant but don't care about time then change .(Participant, Time) to .(Participant) and to change how many samples you grab just change the 2 in sample(AdpMeanAmp, 2) to however many you want.
"His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich