I?ve been retired since ?06 and have forgotten most of R. Now I have a use for it, with some data from Bloomington?s Environmental Commission. I have a dataframe (obtained from read.csv) that contains numerous columns, including time (in Excel?s 18:00 format), and DNO2, and MNO2 from two air quality instruments. I?d like a plot of both the NO2 measurements against time. I be happy to use either ordinary R plots or ggplot2 ones, if that would be a better way. I?d much appreciate help. [[alternative HTML version deleted]]
My version of this email has a bunch of ? that I do not know how to interpret. Emails to this group need to be in plain text. HTML content is deleted or converted and impossible or at least difficult to interpret. Do not share confidential data. Please change some numbers or variable names and share that. If this helps: 1) Make sure your time variable is a datetime object. 2) At least in ggplot it should now behave as expected. ggplot(df, aes(y=NO2, x=datetime)) + geom_point() That will be a start as a scatterplot, but the graph can be customized or changed if scatterplot was not desired. Tim -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Parkhurst, David Sent: Sunday, September 18, 2022 4:27 PM To: r-help at r-project.org Subject: [R] Need help plotting [External Email] I?ve been retired since ?06 and have forgotten most of R. Now I have a use for it, with some data from Bloomington?s Environmental Commission. I have a dataframe (obtained from read.csv) that contains numerous columns, including time (in Excel?s 18:00 format), and DNO2, and MNO2 from two air quality instruments. I?d like a plot of both the NO2 measurements against time. I be happy to use either ordinary R plots or ggplot2 ones, if that would be a better way. I?d much appreciate help. [[alternative HTML version deleted]]
David, Do these work for you? (I am resending this so others can see. The original only went to you.) library(lubridate) a<-c(4, 5, 6) b<-c("18:00", "18:01", "18:02") c<-as.data.frame(cbind(a,b)) c$d<-hm(c$b) c$d$minute[2] I could do it manually like this (where FrHour is fractional hour) a<-c(4, 5, 6) b<-c("18:00", "18:09", "18:42") c<-as.data.frame(cbind(a,b)) c$d<-hm(c$b) c$d$minute[2] c$Hour=as.numeric(substr(c$b,1,2)) c$Second=as.numeric(substr(c$b,4,5)) c$FrHour <- c$Hour + c$Second/60 As I was writing Rui posted another option with code for graphing. Tim -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Parkhurst, David Sent: Sunday, September 18, 2022 4:27 PM To: r-help at r-project.org Subject: [R] Need help plotting [External Email] I?ve been retired since ?06 and have forgotten most of R. Now I have a use for it, with some data from Bloomington?s Environmental Commission. I have a dataframe (obtained from read.csv) that contains numerous columns, including time (in Excel?s 18:00 format), and DNO2, and MNO2 from two air quality instruments. I?d like a plot of both the NO2 measurements against time. I be happy to use either ordinary R plots or ggplot2 ones, if that would be a better way. I?d much appreciate help. [[alternative HTML version deleted]]
Hi David, Since you used read.csv to get the data frame, the file must be i text format. If you can include a few lines of the input (with made up NO2 values if necessary), it would be easy to respond with the required commands and a plot. Jim On Mon, Sep 19, 2022 at 9:12 PM Parkhurst, David <parkhurs at indiana.edu> wrote:> > I?ve been retired since ?06 and have forgotten most of R. Now I have a use for it, with some data from Bloomington?s Environmental Commission. > > I have a dataframe (obtained from read.csv) that contains numerous columns, including time (in Excel?s 18:00 format), and DNO2, and MNO2 from two air quality instruments. > > I?d like a plot of both the NO2 measurements against time. I be happy to use either ordinary R plots or ggplot2 ones, if that would be a better way. I?d much appreciate help. > > [[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.