I have a simple little dataset:
> str(SFdischg)
'data.frame': 11932 obs. of 4 variables:
$ date: Factor w/ 11932 levels "1/01/1985","1/01/1986",..: 97 4409 8697 9677 10069 10461 10853 11245 11637 489 ...
$ ddmm: Factor w/ 366 levels "01-Apr","01-Aug",..: 1 13 25 37 49 61 73 85 97 109 ...
$ year: int 1984 1984 1984 1984 1984 1984 1984 1984 1984 1984 ...
$ cfs : int 1500 1430 1500 1850 1810 1830 1850 1880 1970 1980 ...
I would like to have a column of dates so that I can plot temporal data:
SFdischg$daymo <- as.Date(SFdischg$ddmm, format="%d-%b")
> summary(SFdischg)
date ddmm year cfs daymo
1/01/1985: 1 01-Apr : 33 Min. :1984 Min. : 172 Min. :2018-01-01
1/01/1986: 1 01-Aug : 33 1st Qu.:1992 1st Qu.: 705 1st Qu.:2018-04-04
1/01/1987: 1 01-Jul : 33 Median :2000 Median : 948 Median :2018-07-03
1/01/1988: 1 01-Jun : 33 Mean :2000 Mean :1374 Mean :2018-07-02
1/01/1989: 1 01-May : 33 3rd Qu.:2008 3rd Qu.:1340 3rd Qu.:2018-10-01
1/01/1990: 1 01-Nov : 33 Max. :2016 Max. :8100 Max. :2018-12-31
(Other) :11926 (Other):11734 NA's :8
However, daymo
now has 8 NAs and I can't understand why (and it makes it difficult to plot!). Where does the handful of NAs come from when there is no missing data in ddmm
? How can I avoid them? Am I missing something obvious?