Patrik -
I don't know if it's the fastest, but, assuming your
Matrix is called mat, this seems to work fairly quickly:
wh = which(is.na(mat),arr.ind=TRUE)
mat[wh] = apply(mat,2,mean,na.rm=TRUE)[wh[,2]]
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Wed, 15 Dec 2010, patrik.waldm...@djingis.se wrote:
Dear All,
??
does anyone know which is the fastest way to replace NA values in a
Matrix by their column mean?
library(Matrix)
mat
Links:
------
[1] http://www.ownit.se
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org 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.