[R] Read in data table, change columns from factors

Rich Shepard r@hep@rd @end|ng |rom @pp|-eco@y@@com
Thu Jul 19 21:33:11 CEST 2018


On Thu, 19 Jul 2018, Rich Shepard wrote:

> I have the date and elev columns converted from factors to date and
> numeric, respectively, but still have not learned how to convert the time.

   With this dataframe structure,

str(wy2018)
'data.frame':	12592 obs. of  3 variables:
  $ date: Date, format: "2017-10-01" "2017-10-01" ...
  $ time: chr  "00:00" "00:30" "01:00" "01:30" ...
  $ elev: num  290 290 290 290 290 ...

what is my syntax error using chron() to convert the time column?

wy2018$time <- chron(times=wy2018$time)
Error in convert.times(times., fmt) : format h:m:s may be incorrect
In addition: Warning message:
In unpaste(times, sep = fmt$sep, fnames = fmt$periods, nfields = 3) :
   12592 entries set to NA due to wrong number of fields


   Adding a format as either %h:%m or just h:m makes no difference.

Rich




More information about the R-help mailing list