antonio rodriguez wrote:

Hi All,

How do I can delete from a matrix (or array) only those columns which have
all their values set to NA?

Cheers

Antonio Rodriguez
---

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Try:

> x<-matrix(1:16,4,4)
> x[col(x)>=row(x)]<-NA
> x[,! apply(x,2,function(x) all(is.na(x))) ]
    [,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]    2   NA   NA
[3,]    3    7   NA
[4,]    4    8   12

Peter Wolf

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to