Got error message from conversion of character to date

Trying to convert character to date, got error message: "Error in charToDate(x) :
character string is not in a standard unambiguous format"
playoff_brackets <- data_frame(
holiday = 'playoffs',
ds = as.Date(c('2019–04–16','2018–04–17','2017–04–19','2016–04–19'),),
lower_window = 0,upper_window = 45
)

adding format="%Y-%m-%d", still doesn't work, what is wrong?
playoff_brackets <- data_frame(
holiday = 'playoffs',
ds = as.Date(c('2019–04–16','2018–04–17','2017–04–19','2016–04–19'), format="%Y-%m-%d"),
lower_window = 0,upper_window = 45
)
Thank you!

The following works for me. The main change is that I have replaced all of the long dashes in the character strings with the standard shorter ones. That is I used - instead of –.

playoff_brackets <- data_frame(
  holiday = 'playoffs',
  ds = as.Date(c('2019-04-16','2018-04-17','2017-04-19','2016-04-19')),
  lower_window = 0,upper_window = 45
)
1 Like

Yeah, it works now. The sample code was copied from somewhere, I didn't realize dash issue. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.