[R] 0 * NA = NA

Alberto Monteiro albmont at centroin.com.br
Mon Mar 5 15:23:08 CET 2007


Is there any way to "force" 0 * NA to be 0 instead of NA?

For example, suppose I have a vector with some valid values, while
other values are NA. If I matrix-pre-multiply this by a weight 
row vector, whose weights that correspond to the NAs are zero,
the outcome will still be NA:

x <- c(1, NA, 1)
wt <- c(2, 0, 1)
wt %*% x # NA

Alberto Monteiro



More information about the R-help mailing list