[R] deleting specified NA values

BXC (Bendix Carstensen) bxc at steno.dk
Mon Nov 1 16:44:38 CET 2004


How about:

all.nas <- apply( old, 1, function(x) sum( is.na( x ) ) )
new <- old[all.nas < dim( old )[2], ]

----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
bxc at steno.dk
www.biostat.ku.dk/~bxc
----------------------



> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Robert 
> Brown FM CEFAS
> Sent: Monday, November 01, 2004 4:18 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] deleting specified NA values
> 
> 
> I have a data set of about 10000 records which was compiled 
> from several smaller data sets using SPSS. During compilation 
> 88 false records were accidentally introduced which comprise 
> all NA values.  I want to delete these records but not other 
> missing data.  The functions na.exclude and na.omit seem to 
> remove all values of NA? How can I delete just the relevant 
> NA's?  . i.e. I want to delete  all records in the data frame 
> DATA where the field age contains NA values
> 
> Regards,
> 
> Robert Brown
> 
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list