[R] reexpand a matrix after subsetting

From: Ido M. Tamir <tamir_at_imp.univie.ac.at>
Date: Tue 30 Aug 2005 - 02:11:12 EST


Hi,

suppose I have a matrix (or dataframe)
as a result from subsetting.

mat <- matrix(1:20,ncol=2)
mat[c(3,6,9),] <- NA
cc <- complete.cases(mat)
sub <- mat[cc,,drop=FALSE]
sub <- sub * 2
#some caluculations with sub.

now I would like to expand sub somehow
so row 3,6, and 9 would be filled with
NAs but the rest should be in place again. Is there a simple function for this?

merge is not an option.

Thank you very much for your help.

Ido

      [,1] [,2]
[1,] 2 22
[2,] 4 24
[3,] NA NA
[4,] 8 28
[5,] 10 30
[6,] NA NA
[7,] 14 34
[8,] 16 36
[9,] NA NA

[10,] 20 40



R-help@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 Received on Tue Aug 30 02:15:39 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:57 EST