Re: [R] row subtraction

2009-10-25 Thread Ben Bolker
Marsha Melnyk wrote: > > I don't know if there is a way to do this in R but I want to subtract > within the same column from different rows. I want to subtract > c(r)-c(r-1) and continue down the column until they are all calculated > and form another column. Again I don't know if R can do

Re: [R] row subtraction

2009-10-25 Thread Ista Zahn
If I understand what you're asking this is one (although probably not the easiest or best) way: X <- as.data.frame(matrix(runif(50), nrow=10)) X.tmp <- rbind(rep(NA, dim(X)[2]), X[1:(dim(X)[1]-1),]) X.new <- X - X.tmp -Ista On Sun, Oct 25, 2009 at 5:45 PM, Marsha Melnyk wrote: > I don't know

[R] row subtraction

2009-10-25 Thread Marsha Melnyk
I don't know if there is a way to do this in R but I want to subtract within the same column from different rows. I want to subtract c(r)-c(r-1) and continue down the column until they are all calculated and form another column. Again I don't know if R can do this but I thought I would ask. T