Why NA, when chr type was changed into POSIXlt?

I changed the character data type (2020-03-12) of the Date variable in my data set into POSIXlt, but got instead of the format 2020-03-12 a NA with all options of format, see screenshot.

Where is the mistake?

what is this strange <local> syntax, it doesnt appear to be R...?
also you have mispelled lubridate. by ptting a d after the b

Please post the output of

dput(head(data_birds$Date))

Put a line with three back ticks just before and after the output, like this
```
output of dput() goes here
```

It was previously written in the second data set after a format change from chr
to POSIXlt with strptime. In con-sequence, I thought the whole function
is POSIXlt . Now, it is unexplain- able lost in the second data set. How - ever, I do not guess anymore, that it is important and should only point out
that the format is local specific.

Here, I deal with the first data set. When I try to install the package lubridate (even if written right) I get an error message as there is not such a package.

I am entering this platform via the GitHub App on my smartphone, while I handle the data in RStudio on my Laptop, so it is not possible to provide the output via copy and paste between three back ticks, so I’ve to send a foto again.

The dates have been converted to NA values, so you need to read in the data again. If the characters have the format 2020-03-12, then

data_birds$Date <- as.POSIXlt(data_birds$Date, format = "%Y-%m-%d")

should work. Since the first attempt may have had a bad format string, I believe all the dates became NAs and then subsequent attempts to convert the data were futile.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.