Suppose I have:
dat
x1 x2 x3 x4
1 1 2 3 4
2 2 3 4 5
3 3 4 5 6
4 4 5 6 7
I want to read data from variables in a for loop like:
for((i in 1: 4){
y<- dat$paste("x",i,sep="")
sum(y)
}
How can I make it to work?
I want to do many calculations on each (column) variable x1, x2, etc