Starting with year-month-day, for the variable gallons, I can easily plot the variable gallons, while disregarding the date. gallons <- c (15.973, 18.832, 17.392, 14.774, 19.248, 14.913, 15.226, 14.338, 18.777, 19.652) plot (gallons, type="l", xlab="X label", ylab="Y label", col="blue?) How do I direct R to plot the variable gallons, at the appropriate, irregularly-spaced places on the X axis, while paying attention to the year-month-day? format = "%Y-%m-%d? 2020-01-05 15.973 2020-02-15 18.832 2020-03-10 17.392 2020-05-04 14.774 2020-06-21 19.248 2020-08-01 14.913 2020-08-27 15.226 2020-09-28 14.338 2020-11-09 18.777 2020-12-11 19.652 [[alternative HTML version deleted]]
Hi Gregory, Here's a start: gcdf<-read.table(text="2020-01-05 15.973 2020-02-15 18.832 2020-03-10 17.392 2020-05-04 14.774 2020-06-21 19.248 2020-08-01 14.913 2020-08-27 15.226 2020-09-28 14.338 2020-11-09 18.777 2020-12-11 19.652", header=TRUE,stringsAsFactors=FALSE, col.names=c("date","gallons")) gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d") plot(gcdf$date,gcdf$gallons,main="Gallons by date", xlab="Date",ylab="Gallons") Jim On Mon, Dec 14, 2020 at 9:33 AM Gregory Coats via R-help <r-help at r-project.org> wrote:> > Starting with year-month-day, for the variable gallons, I can easily plot the variable gallons, while disregarding the date. > gallons <- c (15.973, 18.832, 17.392, 14.774, 19.248, 14.913, 15.226, 14.338, 18.777, 19.652) > plot (gallons, type="l", xlab="X label", ylab="Y label", col="blue?) > > How do I direct R to plot the variable gallons, at the appropriate, irregularly-spaced places on the X axis, while paying attention to the year-month-day? > > format = "%Y-%m-%d? > 2020-01-05 15.973 > 2020-02-15 18.832 > 2020-03-10 17.392 > 2020-05-04 14.774 > 2020-06-21 19.248 > 2020-08-01 14.913 > 2020-08-27 15.226 > 2020-09-28 14.338 > 2020-11-09 18.777 > 2020-12-11 19.652 > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
By converting the character date data into a time-like type... e.g. ?as.Date and plotting y-vs-x. On December 12, 2020 11:18:46 AM PST, Gregory Coats via R-help <r-help at r-project.org> wrote:>Starting with year-month-day, for the variable gallons, I can easily >plot the variable gallons, while disregarding the date. >gallons <- c (15.973, 18.832, 17.392, 14.774, 19.248, 14.913, 15.226, >14.338, 18.777, 19.652) >plot (gallons, type="l", xlab="X label", ylab="Y label", col="blue?) > >How do I direct R to plot the variable gallons, at the appropriate, >irregularly-spaced places on the X axis, while paying attention to the >year-month-day? > >format = "%Y-%m-%d? >2020-01-05 15.973 >2020-02-15 18.832 >2020-03-10 17.392 >2020-05-04 14.774 >2020-06-21 19.248 >2020-08-01 14.913 >2020-08-27 15.226 >2020-09-28 14.338 >2020-11-09 18.777 >2020-12-11 19.652 > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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.-- Sent from my phone. Please excuse my brevity.