Take a look at this:
x <- matrix(1:9, 3)
x[2,2] <- Inf
x[3,1] <- NA
rowMeans(x * is.finite(x), na.rm = TRUE)
I at first thought you could simply use x[is.finite(x)] but that
looses the matrix-ness of it so instead, we use the fact that 0 * Inf
= NaN which gets killed by na.rm = TRUE. Also see my
Hi all,
I have a csv matrix "KT.csv" and it has Inf and NA
I want to calculate the mean of each row so I use
rowMeans(KT,na.rm = TRUE) but with this Inf cannot be omminted.
I´m trying to use before running rowMeans(KT,na.rm = TRUE)
KT<-range(KT,finite=TRUE)
but it doesn´t works...
Do you kno
2 matches
Mail list logo