[R] Dates and missing values

Göran Broström goran.brostrom at umu.se
Mon Feb 8 18:26:20 CET 2016


I have a data frame with dates as integers:

 > summary(persons[, c("foddat", "doddat")])
      foddat             doddat
  Min.   :16790000   Min.   :18000000
  1st Qu.:18760904   1st Qu.:18810924
  Median :19030426   Median :19091227
  Mean   :18946659   Mean   :19027233
  3rd Qu.:19220911   3rd Qu.:19310526
  Max.   :19660124   Max.   :19691228
  NA's   :624        NA's   :207570

After converting the dates to Date format ('as.Date') I get:

 > summary(per[, c("foddat", "doddat")])
     foddat               doddat
  Min.   :1679-07-01   Min.   :1800-01-26
  1st Qu.:1876-09-04   1st Qu.:1881-09-24
  Median :1903-04-26   Median :1909-12-27
  Mean   :1895-02-04   Mean   :1903-02-22
  3rd Qu.:1922-09-10   3rd Qu.:1931-05-26
  Max.   :1966-01-24   Max.   :1969-12-28

My question is: Why are the numbers of missing values not printed in the 
second case? 'is.na' gives the correct (same) numbers.

Can I somehow force 'summary' to print NA's? I found no clues in the 
documentation.

 > sessionInfo()
R version 3.2.3 Patched (2016-01-19 r69960)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 15.10

Göran Broström



More information about the R-help mailing list