Well, it seems to work with me.

Y <- as.matrix(airquality)
head(Y, n=8)
     Ozone Solar.R Wind Temp Month Day
[1,]    41     190  7.4   67     5   1
[2,]    36     118  8.0   72     5   2
[3,]    12     149 12.6   74     5   3
[4,]    18     313 11.5   62     5   4
[5,]    NA      NA 14.3   56     5   5
[6,]    28      NA 14.9   66     5   6
[7,]    23     299  8.6   65     5   7
[8,]    19      99 13.8   59     5   8

Z <- Y[,complete.cases(t(Y))==T]

head(Z, n=8)
     Wind Temp Month Day
[1,]  7.4   67     5   1
[2,]  8.0   72     5   2
[3,] 12.6   74     5   3
[4,] 11.5   62     5   4
[5,] 14.3   56     5   5
[6,] 14.9   66     5   6
[7,]  8.6   65     5   7
[8,] 13.8   59     5   8

The columns that contained NA were deleted.


Le 27 mars 2015 � 10:38, peter dalgaard <pda...@gmail.com> a �crit :

> 
> On 27 Mar 2015, at 09:58 , St�phane Adamowicz 
> <stephane.adamow...@avignon.inra.fr> wrote:
> 
>> data_no_NA <- data[, complete.cases(t(data))==T]
> 
> Ouch! logical == TRUE is bad, logical == T is worse:
> 
> data[, complete.cases(t(data))]
> 
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd....@cbs.dk  Priv: pda...@gmail.com
> 
> 
> 
> 
> 
> 
> 
> 
> 



_________________________________
St�phane Adamowicz
Inra, centre de recherche Paca, unit� PSH
228, route de l'a�rodrome
CS 40509
domaine St Paul, site Agroparc
84914 Avignon, cedex 9
France

stephane.adamow...@avignon.inra.fr
tel.  +33 (0)4 32 72 24 35
fax. +33 (0)4 32 72 24 32
do not dial 0 when out of France
web PSH  : https://www6.paca.inra.fr/psh
web Inra : http://www.inra.fr/
_________________________________


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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