Re: [R] how to replace NA values in a list

2008-08-02 Thread Satoshi Takahama
- Original Message From: Shang Liu [EMAIL PROTECTED] Subject: [R] how to replace NA values in a list I have a matrix named spec (see below), it is a 6x3 matrix, and each element of spec is a list. For example, spec[1,wavenumber] is a list, and it contains 1876 numeric numbers and NAs

[R] how to replace NA values in a list

2008-08-01 Thread Shang Liu
I have a matrix named spec (see below), it is a 6x3 matrix, and each element of spec is a list. For example, spec[1,wavenumber] is a list, and it contains 1876 numeric numbers and NAs. I want to replace the NAs to zero, but don't know how to change it, the difficulty may be all the elements are

Re: [R] how to replace NA values in a list

2008-08-01 Thread Roland Rau
Hi, to be honest, I never created a matrix of lists before, but hopefully this code will help you? set.seed(12345) my.pool - c(NA, 0:10) n - 25 alist - list(sample(x=my.pool, size=n, replace=TRUE)) alist mymatrix - matrix(rep(alist, 6*3), nrow=6) mymatrix2 - lapply(X=mymatrix,