This is my first post so please bear with me. Below is a small sample of my data. My actual dataset has over 4,000 individual IDs and each ID can have anywhere from one to two hundred separate dollar amounts assigned to it.
ID Dollars
001 17000
001 18000
001 23000
002 64000
002 31000
003 96000
003 164000
003 76000
What I'm essentially trying to do can be best explained using an example. I want generate five random samples, with replacement, for each ID. Each sample would have a size of 5 or 5 randomly sampled dollar values. My final result would have 20,000 separate samples (5 samples, per 4000 IDs, each containing 5 randomly selected dollar amounts by ID). I am doing this in order to compare the distributions of dollars in each sample to their fellow samples with the same ID.
As of right now, I'm attempting to garner such an answer using the code referenced below. I should also point out that when I run this script I receive an error that my 'results must be all atomic'. I'm not sure if I need to add additional steps or what.
x <- function(func)
{
func<-(lapply(1:5, function(i)
sample(data$Dollars, size=5, replace=TRUE)))
}
grouped.samples<-ddply(data,.variables="ID",.fun=x)
I’m sorry in advance if the question I posed was unclear; I had difficulty articulating the problem I'm having.
Thanks in advance for your help