Re: [R] Summing x1 to x6

2011-12-20 Thread Pablo
Thank you guys for your suggestions! Florent D - that probably is the way of writing what I had in my head. The suggestion I took up was one of JHoltman's which he put in an e-mail to me following his initial post but it works well with the vectors in this question: require(plyr) x1.6 <- laply(1

Re: [R] Summing x1 to x6

2011-12-19 Thread Florent D.
>> I tried to be clever by trying get(paste(paste("x", 1:6, sep=""), >> collapse="+")) but it didn't work. Maybe you meant something like this: sapply(paste("x", 1:6, sep=""), function(x)mean(get(x))) On Mon, Dec 19, 2011 at 2:30 PM, David Winsemius wrote: > > On Dec 19, 2011, at 11:00 AM, Pab

Re: [R] Summing x1 to x6

2011-12-19 Thread David Winsemius
On Dec 19, 2011, at 11:00 AM, Pablo wrote: Suppose I have the following: x1<-as.vector(rnorm(10)) x2<-as.vector(rnorm(10)) x3<-as.vector(rnorm(10)) x4<-as.vector(rnorm(10)) x5<-as.vector(rnorm(10)) x6<-as.vector(rnorm(10)) x7<-as.vector(rnorm(10)) x8<-as.vector(rnorm(10)) x9<-as.vector(rnorm(1

Re: [R] Summing x1 to x6

2011-12-19 Thread jim holtman
Not sure what you mean by mean of each position, so here are two possibilities: rowMeans and colMeans: > x1<-as.vector(rnorm(10)) > x2<-as.vector(rnorm(10)) > x3<-as.vector(rnorm(10)) > x4<-as.vector(rnorm(10)) > x5<-as.vector(rnorm(10)) > x6<-as.vector(rnorm(10)) > x7<-as.vector(rnorm(10)) > x8<-

[R] Summing x1 to x6

2011-12-19 Thread Pablo
Suppose I have the following: x1<-as.vector(rnorm(10)) x2<-as.vector(rnorm(10)) x3<-as.vector(rnorm(10)) x4<-as.vector(rnorm(10)) x5<-as.vector(rnorm(10)) x6<-as.vector(rnorm(10)) x7<-as.vector(rnorm(10)) x8<-as.vector(rnorm(10)) x9<-as.vector(rnorm(10)) x10<-as.vector(rnorm(10)) I would like the