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:
Hello, I have 49 paired data, x, y.
I have sampled x (where replacement is true), and find its mean.
How can I find the corresponding mean y, which is the paired data of above
sample x?
Thank you very much,
Annie

--
Greg Hirson
ghir...@ucdavis.edu

Graduate Student
Agricultural and Environmental Chemistry

1106 Robert Mondavi Institute North
One Shields Avenue
Davis, CA 95616

______________________________________________
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.

Reply via email to