Dear R users;
Consider the following toy example:
a - matrix(c(2,3,4,NA,NA,5,8,NA,8,NA), 5, 2)
b - cbind(a,apply(a, 1, diff, na.rm = TRUE))
What I would like be able to get is:
c - matrix(c(2,3,4,NA,NA,5,8,NA,8,NA,3,5,-4,8,NA), 5, 3)
i.e., for each row if both values (column 1 and 2) are NA
.
- Original Message -
From: Pedro Mardones mardone...@gmail.com
To: R-help@r-project.org
Cc:
Sent: Wednesday, March 13, 2013 5:43 PM
Subject: [R] calculating column difference in a matrix
Dear R users;
Consider the following toy example:
a - matrix(c(2,3,4,NA,NA,5,8,NA,8,NA), 5, 2)
b
2 matches
Mail list logo