Skip to content
Prev 206010 / 398506 Next

find the corresponding mean y

Annie,

If I understand what you are asking, you want to sample some number of 
observations, with replacement, then find the mean of x and y for those 
observations.

In this case, you would want to sample the row indices instead of the 
values. For example,

     #test data
set.seed(1)
df <- data.frame(x = rnorm(100), y = rnorm(100))
     #sample from row indices
samp <- sample(nrow(df), 25, replace = TRUE)

     #get means for x and y
mean(df[samp,]$x)
mean(df[samp,]$y)
     #or
mean(df[samp,])

Greg
On 1/11/10 9:42 AM, luciferyan wrote: