Skip to content
Prev 387437 / 398502 Next

How to plot dates

Hi,

It doesn't have anything to do with having a Mac - you have POSIX.

It's because something is wrong with your data import. Looking at the
head() output you provided, it looks like your data file does NOT have
a header, because there's no datetime column, and the column name is
actually X2021.03.11.10.00.0

So you specified a nonexistent column, and got a zero-length answer.

With correct specification, the as.POSIXct function works as expected on Mac:


myDat <- read.table(text =
"datetime
2021-03-11 10:00:00
2021-03-11 14:17:00
2021-03-12 05:16:46
2021-03-12 09:17:02
2021-03-12 13:31:43
2021-03-12 22:00:32
2021-03-13 09:21:43",
sep = ",", header = TRUE)


myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format =
"%Y-%M-%d %H:%M:%OS")

Sarah

On Tue, Mar 16, 2021 at 9:26 AM Gregory Coats via R-help
<r-help at r-project.org> wrote: