From: Economics Guy <economics.guy_at_gmail.com>

Date: Sun, 17 Jun 2007 16:46:27 -0400

R-help_at_stat.math.ethz.ch 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 Sun 17 Jun 2007 - 20:51:06 GMT

Date: Sun, 17 Jun 2007 16:46:27 -0400

Based on help files and searching the archives and help from the listserv I
have managed to build my monte carlo program.

I took out some of the crazy code I was writing, but here is what I have:

rm(list = ls(all = TRUE))

# removes everything

a <-c("A","C","B","A","B","C")

output.matrix <- matrix(0.0,3,N)

#I need to START LOOP HERE

a <- sample(a, replace=TRUE)

c <-data.frame(b,a)

output.vector <- by(c, a, function(x) sum(x$b))

output.vector <- as.vector(output)

output.vector <- data.frame(output)

#END LOOP here

What I would like to have at the end is the "output.matrix" contain as a column the "output.vector" from each iteration. The actual data frame I will be running has 60,000 observations and I am going to run 20000 iterations so speed is important too.

Thanks so much

EG

[[alternative HTML version deleted]]

R-help_at_stat.math.ethz.ch 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 Sun 17 Jun 2007 - 20:51:06 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 Mon 18 Jun 2007 - 01:32:06 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.
*