NA missing value :: complete.cases

Published onesixx on

 

 

 

> airquality[1:7,]
  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

> complete.cases(airquality[1:7,])
[1]  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE

> as.numeric(complete.cases((airquality[1:7,])))
[1] 1 1 1 1 0 0 1

> sum(as.numeric(complete.cases((airquality[1:7,]))))
[1] 5

행별로 NA가 포함되어 있으면 FALSE

> str(airquality)
'data.frame':	153 obs. of  6 variables:

> str(airquality[complete.cases(airquality),])
'data.frame':	111 obs. of  6 variables:

> str(airquality[!complete.cases(airquality),])
'data.frame':	42 obs. of  6 variables:

 

 

 

 

 

 

Categories: Reshaping

onesixx

Blog Owner

Leave a Reply

Your email address will not be published.