datetime - Add a vector of days and hours to plot in R -
i add concise date , time info plot in r.
i adding plot research paper , when it's shrunk fit template loses of it's info.
my actual datetime range 20/07/2017 18:15 - 23/07/2017 21:15
i'd abbreviate date days such thur 18:15 , sun 21:15 5 days , times in between.
i can create correct range in posixlt format it's big needs.
my.date <- seq(as.posixlt(strptime('20/07/2017 18:15',"%d/%m/%y %h:%m"),tz="gmt"), as.posixlt(strptime('23/07/2017 21:15',"%d/%m/%y %h:%m"),tz="gmt"),length.out = 7)
is there better way achieve datetime rage?
the key problem convert posix object character string desired format. format function used here: format(my.date, "%a %h:%m")
here simple example:
my.date <- seq(strptime('20/07/2017 18:15',"%d/%m/%y %h:%m"), strptime('23/07/2017 21:15',"%d/%m/%y %h:%m"), length.out = 7) #x axis labels in desired format labels<-format(my.date, "%a %h:%m") #simple example base graphics y<-2:8 plot(my.date,y, axes=false) #draw x , y axis axis(1, at=my.date, labels=labels) axis(2, at=y)
Comments
Post a Comment