Hi Greg, I think this does what you want: gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d") grid_dates<-as.Date(paste(2014:2020,1,1,sep="-"),"%Y-%m-%d") plot(gcdf$date, gcdf$gallons, main="2014 Toyota 4Runner", xlab="Date", ylab="Gallons",type="l",col="blue",yaxt="n") abline(h=seq(4,20,by=2),lty=4) abline(v=grid_dates,lty=4) axis(side=2,at=seq(4,20,by=2))
Jim On Wed, Dec 16, 2020 at 2:16 PM Gregory Coats <gregco...@me.com> wrote: > > Jim, Thanks for your help with R. > Feeding into R the file R_plot_18.r yields for me, on my Mac, R_plot_18.pdf. > Success. > I used abline to draw a horizontal background grid, and then used axis label > to identify the values represented by the horizontal dashed background lines. > abline (h=c(2,4,6,8,10,12,14,16,18,20,22,24), lty=4, lwd=1.0, col="grey60") > Similarly, I would like to draw a dashed vertical background grid. But it is > unclear to me how to direct R to draw a vertical dashed background grid > because I am again baffled how to specify to R a date value such as > 2018-10-20 @18:00. I welcome your guidance. > Greg > > > On Dec 13, 2020, at 10:58 PM, Jim Lemon <drjimle...@gmail.com> wrote: > > Hi Gregory, > > On Mon, Dec 14, 2020 at 12:34 PM Gregory Coats <gregco...@me.com> wrote: > > ... > Is there a convenient way to tell R to interpret “2020-12-13” as a date? > > Notice the as.Date command in the code I sent to you. this converts a > string to a date with a resolution of one day. If you want a higher > time resolution, use strptime or one of the other POSIX date > conversion functions. > > Jim > > ______________________________________________ R-help@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.