tags:

views:

64

answers:

1

I have the following statement. I seem to have to repeat myself by writing out the numbers myself. Using seq(-1,-9,-1) or -1:-9 doesn't seem to work. Is there another way to speak with R?

difnormsum<-rowSums(data.frame(difnorm[[1]][-nrow(difnorm)],difnorm[[1]][-1], 
difnorm[[1]][-2],difnorm[[1]][-3],difnorm[[1]][-4],difnorm[[1]][-5],
difnorm[[1]][-6],difnorm[[1]][-7],difnorm[[1]][-8],difnorm[[1]][-9]))
+1  A: 

You could try

 rowSums(data.frame(
     lapply(c(nrow(difnorm),1:9), function(i) difnorm[[1]][-i])
 ))
Marek