Skip to content
Prev 239738 / 398500 Next

How to perform arithmetic across rows

Hi Nick,

Take a look at ?cbind and ?"["

Here is some (untested) code that is how I might go about it.  It
takes advantage of the fact that a single value will be recycled to
equal the necessary length.  Then I just assign over the NA in row 24.

myframe <- cbind(myframe, New = NA)
myframe[24, "New"] <- with(myframe, A[1] - A[24])

New will be an all NA column except for row 24.

Cheers,

Josh
On Thu, Oct 28, 2010 at 11:47 AM, Nick Ackerman <nick.ackerman at pgn.com> wrote: