[R] remove pairs of missing values

Jose A. Hernandez jahernan at umn.edu
Wed Mar 17 23:12:24 CET 2004


I think the easiest way is using na.omit function which omits pairs of data

Look at the following example:

 > x <- c(0,1,2,3,4,5)
 > y <- c(NA,2, 3, 5, NA, 6)
 > data.1 <- data.frame(x,y)
 > data.1
   x  y
1 0 NA
2 1  2
3 2  3
4 3  5
5 4 NA
6 5  6
 > new.data <- na.omit(data.1)
 > new.data
   x y
2 1 2
3 2 3
4 3 5
6 5 6
 >

-- 
Jose A. Hernandez
Ph.D. Candidate
Precision Agriculture Center

Department of Soil, Water, and Climate
University of Minnesota
1991 Upper Buford Circle
St. Paul, MN 55108

Ph. (612) 625-0445, Fax. (612) 625-2208




More information about the R-help mailing list