I have ncdf file that can be download here. This dataset contains two variables (TA and DMI). TA value represents the date with unit MONTHS since 1800-01-01 00:00:00. How to convert the TA value into date (as.Date)?
Here my code:
x<-open.ncdf('dmi.cdf')x$
dmi<-get.var.ncdf(x, varid = 'DMI')
ta<-get.var.ncdf(x, varid = 'TA')
date<-as.Date(ta, origin=c('1800-01-01'))
Here I give a result from my code for 12 first row of my dataset. I should be by month not by day.
> ta[1:12]
[1] 853.0192 854.0198 855.0205 856.0211
[5] 857.0218 858.0225 859.0231 860.0238
[9] 861.0244 862.0251 863.0257 864.0264
> as.Date(ta[1:12], origin=c('1800-01-01'))
[1] "1802-05-04" "1802-05-05" "1802-05-06" "1802-05-07"
[5] "1802-05-08" "1802-05-09" "1802-05-10" "1802-05-11"
[9] "1802-05-12" "1802-05-13" "1802-05-14" "1802-05-15"
The result that I expected below (i.e. but the year, I'm not sure it's right 1802)
[1] "1802-01-01" "1802-02-01" "1802-03-01" "1802-04-01"
[5] "1802-05-01" "1802-06-01" "1802-07-01" "1802-08-01"
[9] "1802-09-01" "1802-10-01" "1802-11-01" "1802-12-01"