[R] matrix manipulation question

Jatin Kala jatin.kala.jk at gmail.com
Fri Mar 27 06:13:24 CET 2015

I've got a rather large matrix of about 800 rows and 600000 columns.
Each column is a time-series 800 long.

Out of these 600000 time series, some have missing values (NA).
I want to strip out all columns that have one or more NA values, i.e., 
only want full time series.

This should do the trick:
data_no_NA <- data[,!apply(is.na(data), 2, any)]

I now use data_no_NA as input to a function, which returns output as a 
matrix of the same size as data_no_NA

The trick is that i now need to put these columns back into a new 800 by 
600000 empty matrix, at their original locations.
Any suggestions on how to do that? hopefully without having to use loops.
I'm using R/3.0.3


More information about the R-help mailing list