0

I'm sure there is a simple solution, but I can't work it out and googling isn't helping me.

If I want to find the max of each row within the boundaries I do this:

temp.df$S1max <- apply(S1[135:175], 1, max)

But how can I apply this to regions outside of that bounds? This doesn't work:

temp.df$S1mean <- apply(S1[0:135, 175:300], 1, mean)

Thanks

Daniel
  • 289
  • 2
  • 14

1 Answers1

4

You can use negative indexing:

apply(S1[-c(135:175)], 1, mean)
Vincent Bonhomme
  • 7,235
  • 2
  • 27
  • 38