Message-ID: <D0B46B0A-E5E2-4807-9847-50D97BD2904F@me.com>
Date: 2021-03-16T13:25:38Z
From: Gregory Coats
Subject: How to plot dates
In-Reply-To: <2DB01128-C5DA-4D02-961B-C784B09033BD@me.com>
My computer is an Apple MacBook. I do not have POSIX.
The command
myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format = "%Y-%M-%d %H:%M:%OS")
yields the error
Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) :
replacement has 0 rows, data has 13
Please advise, How to proceed?
Greg Coats
> library(ggplot2)
> # Read a txt file on the Desktop, named "myDat.txt"
> myDat <- read.delim("~/Desktop/myDat.txt", header = TRUE, sep = ",")
> head(myDat)
X2021.03.11.10.00.00
1 2021-03-11 14:17:00
2 2021-03-12 05:16:46
3 2021-03-12 09:17:02
4 2021-03-12 13:31:43
5 2021-03-12 22:00:32
6 2021-03-13 09:21:43
> # convert data to date time object
> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format = "%Y-%M-%d %H:%M:%OS")
Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) :
replacement has 0 rows, data has 13
>
[[alternative HTML version deleted]]