Skip to content
Back to formatted view

Raw Message

Message-ID: <507901BE06452C498E8CE9ADBC698C6C0E9CFFF1@KIMSX04.user.ki.se>
Date: 2011-02-10T20:53:28Z
From: Marine Andersson
Subject: Calculating rowMeans from different columns in each row?

Hello!

I have a dataset like this:

X1   X2   X3   X4   X5    X6    X7    X8
1     2      2     1     2      3       2      6
2     3      2     5     7      9       1      3
1    9     12     6     1      1       3      6

The columns X1-X6 contains ordinary numeric values. 

X7 contains the number of the first column that the rowMeans should be calculated from and 
X8 contains the last column that should be included in the rowMeans.

when I try

test <- (df[,df$X7:df$X8])

the rowMeans are calculated based on the values in the X7 and X8 in the first row only.

Thanks in advance!

/Marine