[R] How to plot dates

Jeff Reichman re|chm@nj @end|ng |rom @bcg|ob@|@net
Mon Mar 15 22:52:19 CET 2021


Gregory

myDat <- data.frame(datetime = c("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","2021-03-13 13:51:12",
           "2021-03-13 18:03:13","2021-03-13 22:20:28","2021-03-14
08:59:03","2021-03-14 13:15:56",
           "2021-03-14 17:25:23","2021-03-14 21:36:26"))

# convert date to date time object
myDat$ datetime <- as.POSIXlt(myDat$ datetime, tz = "", format = "%Y-%M-%d
%H:%M:%OS")

# plotting
ggplot(myDat, aes(datetime, <y variable>)) .....

Jeff

-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Gregory Coats via
R-help
Sent: Monday, March 15, 2021 4:34 PM
To: r-help mailing list <r-help using r-project.org>
Subject: [R] How to plot dates

I store in a text file the dates and times that an event occurred.
How do I direct R to import these text characters, and store the year,
month, day, hour, minute, and second as a date?
How do I then plot this series of dates?
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
2021-03-13 13:51:12
2021-03-13 18:03:13
2021-03-13 22:20:28
2021-03-14 08:59:03
2021-03-14 13:15:56 
2021-03-14 17:25:23
2021-03-14 21:36:26
Greg Coats
gregcoats using me.com


	[[alternative HTML version deleted]]

______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list