Displaying 2 results from an estimated 2 matches for "mat_zeroless".
2008 Aug 13
2
missing TRUE/FALSE error in conditional construct
...post.
I am trying to use conditional formatting to select non-zero and non-NaN
values from a matrix and pass them into another matrix. The problem is that
I keep encountering an error message indicating the ":missing value where
TRUE/FALSE needed "
My code is as follows:
##Code Start
mat_zeroless<-matrix(NA,5000,2000) #generating holding matrix
##Assume source matrix containing combination of values, NaNs and zeros##
for (j in 1:5000)
{
for (k in 1:2000)
{
if(mat[j,k]!=0 & !is.NaN(mat[j,k])) {mat_zeroless[j,k]<-mat[j,k]}
}
}
##Code End
Error in if (mat[j...
2008 Aug 12
7
ignoring zeros or converting to NA
Hi everyone,
I have a matrix that has a combination of zeros and NAs. When I perform
certain calculations on the matrix, the zeros generate "Inf" values. Is
there a way to either convert the zeros in the matrix to NAs, or only
perform the calculations if not zero (i.e. like using something similar to
an !all(is.na() construct)?
Thanks,
rcoder
--
View this message in context: