Alberto Monteiro napsal(a): > Is there any way to "force" 0 * NA to be 0 instead of NA?
No (AFAIK), and it is pretty reasonable to define it this way. If you want to treat the NAs as zeros, use x[is.na(x)] <- 0 Petr > 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 > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
