[R] How to plot dates
Gregory Coats
gregco@t@ @end|ng |rom me@com
Tue Mar 16 14:25:38 CET 2021
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]]
More information about the R-help
mailing list