apply(y,2,mean) Is this what you are after. If it is I would suggest that you look at the examples not just for this but for what I call the apply family sapply, tapply, mapply. Once you get the hang of these they are really helpful.
Tom. > -----Original Message----- > From: Thomas Hopper [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 11 January 2005 11:46 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Calculate Mean of Column Vectors? > > > Hello, > > I've got an array defined as y <- rnorm(3000), dim(y) <- c(3, 1000). > > I'd like to produce a 1000-element vector z that is the mean of the > corresponding elements of y (like z[1,1] <- mean(y[1,1], y[2,1], > y[3,1])), but being new to R, I'm not sure how to do this for all > elements at once (or, at least, simply). Any help is appreciated. > > Thanks, > > Tom > > ______________________________________________ > R-help@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 > ______________________________________________ R-help@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