From: Anthony28 <argrenway_at_yahoo.com.au>

Date: Thu, 29 May 2008 07:09:57 -0700 (PDT)

Date: Thu, 29 May 2008 07:09:57 -0700 (PDT)

I need to repeat an experiment 1000 times. Each experiment involves randomly selecting one ball each from two separate bags. Each bag contains 10 balls, numbered 1, 2, 3, ... , 10. So the probability of selecting any one pair of balls is equal to all others.

output <- matrix(nrow=2, ncol=1000)

#I'm attempting to output a vector with 2 rows and 1000 columns. Each column

represents the outcome of one experiment. I don't even know if what I've
written above is allowed.

for (i in 1:1000){

ball1 <- sample(1:10,1)

ball2 <- sample(1:10,1)

A <- max(ball1, ball2)

B <- min(ball1, ball2)

output[i] <- matrix(nrow=2, ncol=1000, data=c(A, B))
}

# This gives me the message that "number of items to replace is not a

multiple of replacement length". I would really appreciate it if someone
could tell me how to do what I intended above properly. Also if anyone has
time, I would like to know how to filter down the (2 x 1000) matrix to
contain only those elements with a particular B-value so that I can then
calculate the conditional means of the A-values.

-- View this message in context: http://www.nabble.com/Calculating-conditional-mean-of-large-series-of-experiments-tp17536218p17536218.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help_at_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.Received on Thu 29 May 2008 - 16:55:17 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 30 May 2008 - 00:30:42 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*