0

I have a dataframe as follows

 df <- data.frame(matrix(rnorm(60), nrow=20))

and would like to find the sum of rows as follows:
Adding the first row to the 11th, second row to the 12th, third to 13th, fourth to 14th, until ten to 20th.

This is just a sample and I would like to do this to a dataframe with 150 rows and 20 columns.

Jaap
  • 81,064
  • 34
  • 182
  • 193
user1805343
  • 127
  • 1
  • 2
  • 11

1 Answers1

1

For your example, you could use

DF <- data.frame(matrix(rnorm(60), nrow=20))
DF[1:10,] + DF[11:20,]
James Trimble
  • 1,868
  • 13
  • 20