completely confused about how lubridate works

If you’re sure date is a string column consisting of dates and times in a format compatible with ymd_hms then this should work. (You might also try as.POSIXct to see if that also throws an error). So I would suspect that either the dates in that column are not all in the same format, or something else is going on. Again, an example of your data will help us help you (as will the error message you receive).

In general a minimal working example (also known as reprex - reproducible example) that shows your error with as little extraneous detail/code as possible, is extremely helpful for anyone trying to help you.

It may also help you help yourself because in constructing a reduced dataset, minimal code etc, you’ll often realise where the error is yourself. It’s an extremely useful problem solving tool.

/r/RStudio Thread Parent