[R] searching through a matrix
Spencer Graves
spencer.graves at pdf.com
Mon Feb 28 00:53:47 CET 2005
Does the following solve your problem:
is.na(array(c(NA, 1:5), dim=c(2,3)))
[,1] [,2] [,3]
[1,] TRUE FALSE FALSE
[2,] FALSE FALSE FALSE
spencer graves
Jessica Higgs wrote:
> I am trying to search through a matrix I have (x) to see if there are
> any missing values. This is what I have been using:
>
> for (i in 1:3455)
> for (j in 1:24)
> if (is.na(x[i,j])) break;
>
> i
> j
>
> When I run the program, it either freezes or stops and returns the
> last entry in the matrix (x[3455,24]). I need to figure out what
> values in my data matrix are missing because I am using prcomp and it
> keeps giving me an error starting that there are missing or infinite
> values in x. My data matrix does have some values that are equal to
> zero but zero doesn't mean that the data is missing. it just indicates
> that that value is equivalent to zero. Any suggestions for how to fix
> this problem?
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list