I would like R to recognize one column as date. It is read as factor during the import, however, when I try to format with 'as.Date' and 'format' I only get NAs. I'm not sure where I'm going wrong.
> d = read.table("ByMonth.Year_54428.txt", header=T, sep=",")
> str(d)
'data.frame': 607 obs. of 2 variables:
$ V1 : Factor w/ 607 levels "1950-12","1951-01",..: 1 2 3 4 5 6 7 8 9 10 ...
$ Rain: int 100 56000 29293 37740 19649 41436 58067 51082 49629 62680 ...
>
>
> Date.form1 <- as.Date(d$V1, "%Y-%m")
> str(Date.form1)
Date[1:607], format: NA NA NA NA NA NA NA NA NA NA NA NA NA NA ...
>
> Date.form2 = as.Date(as.character(d$V1), format="%Y-%m")
> str(Date.form2)
Date[1:607], format: NA NA NA NA NA NA NA NA NA NA NA NA NA NA ...