Hi,

Is there a quick way to go from this matrix:
> A
     [,1] [,2] [,3]
[1,]    1    1    1
[2,]    2    2    2
[3,]    3    3    3
[4,]    4    4    4
[5,]    5   NA    5
[6,]   NA   NA    6
[7,]   NA   NA   NA

to this matrix:
> B
     [,1] [,2] [,3]
[1,]    1   NA   NA
[2,]    2   NA    1
[3,]    3    1    2
[4,]    4    2    3
[5,]    5    3    4
[6,]   NA    4    5
[7,]   NA   NA    6

without using a loop? 
For example using a vector which describes how many NA's are required from
the "top" of the matrix- so in this case it would be c(0,2,1).

Many thanks Emma


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-Manipulation-tp3027266p3027266.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to