I'm looking to find the max values of different columns based on specified rows of each column.
My actual data frame is 50K columns and 1K+ rows so I can't use a loop without greatly increasing run time.
Data Frame:
| row | V1 | V2 | V3 | V4 |
|---|---|---|---|---|
| 1 | 5 | 2 | 4 | 5 |
| 2 | 3 | 5 | 1 | 6 |
| 3 | 7 | 3 | 2 | 6 |
| 4 | 2 | 5 | 3 | 10 |
| 5 | 6 | 9 | 1 | 2 |
beg_row <- c(2, 1, 2, 3)
end_row <- c(4, 3, 3, 5)
output:
c(7, 5, 2, 10)