jbryer/timeline

Ambiguous Date Format Misunderstanding

bryanhanson opened this issue · 1 comments

  1. Thanks for writing this package!
  2. Here's my problem, CRAN & devel version behave the same:
library("lubridate")
library("timeline")
st <- ymd("2013-05-27")
wks <- st + 1:10*dweeks()
df <- data.frame(StartDate = wks[1:9], EndDate = wks[2:10])
# df$StartDate <- as.POSIXlt(df$StartDate) # doesn't fix it
# df$EndDate <- as.POSIXlt(df$EndDate)
df$task <- c(rep(NA, 7), "prep poster", "prep poster")
timeline(df, start.col = "StartDate", end.col = "EndDate")

Gives the following error message:

Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format

But str(df) seems correct:

 str(df)
'data.frame':   9 obs. of  3 variables:
 $ StartDate: POSIXct, format: "2013-06-03" "2013-06-10" "2013-06-17" "2013-06-24" ...
 $ EndDate  : POSIXct, format: "2013-06-10" "2013-06-17" "2013-06-24" "2013-07-01" ...
 $ task     : chr  NA NA NA NA ...

I'm sure this is my misunderstanding. Thank you! Bryan

Alright, as I thought, my misunderstanding. I need to provide more data. Here's a working version:

library("lubridate")
library("timeline")
st <- ymd("2013-05-27")
wks <- st + 1:10*dweeks()
labs <- c(rep(NA, 7), "prep\nposter", "prep\nposter")
group <- rep("task", 9)
df <- data.frame(labels = labs, groups = group, StartDate = wks[1:9], EndDate = wks[2:10])
timeline(df)

Maybe a check in the code for a minimal data set is warranted, maybe not. Bryan