[R] Casting Date to char

Rich Shepard r@hep@rd @ending from @ppl-eco@y@@com
Wed Sep 5 22:17:54 CEST 2018


   I've read the help for as.Date: "Date Conversion Functions to and from
Character" but the method as.character(x ...) isn't working for me:

> str(dp)
'data.frame':	113569 obs. of  2 variables:
  $ rainfall.sampdate: Date, format: "2005-01-01" "2005-01-02" ...
  $ rainfall.prcp    : num  0.59 0.08 0.1 0 0 0.02 0.05 0.1 0 0.02 ...
> dp$sampdate <- as.Character(dp$sampdate)
Error in `$<-.data.frame`(`*tmp*`, sampdata, value = character(0)) :
   replacement has 0 rows, data has 113569

   I don't understand the error message and want to learn what I've done
incorrectly.

Regards,

Rich



More information about the R-help mailing list