Re: [R] Need help plotting

2022-09-23 Thread Jim Lemon
Hi David,
No, read.table converts a text representation of data into a data frame object.

Jim

On Sat, Sep 24, 2022 at 2:29 AM DFP  wrote:
>
> Do I need that read.table if the tst dataframe already exists in my
> system?  If so, why?
>
> --
>
> Hello,
>
> You have to load the packages involved:
>
>
> library(dplyr)
> library(tidyr)
> library(ggplot2)
>
>
> then run the full sequence. Though this is not important, if you are
> pivotting columnns named y1 and y2, why not name the result just y?
>
>
> pivot_longer(-time, names_to = "y")
>
>
> And here is complete code, runs in a fresh R session.
>
>
> tst  <- read.table(text = "
> time y1 y2
> 1  18:55 30 19
> 2  18:56 30 19
> 3  18:57 29 19
> 4  18:58 31 19
> 5  18:59 28 19
> 6  19:00 28 19
> 7  19:01 28 19
> 8  19:02 28 19
> 9  19:03 28 19
> 10 19:04 28 19
> 11 19:05 29 19
> ", header = TRUE)
>
> library(dplyr)
> library(tidyr)
> library(ggplot2)
>
> tst %>%
> mutate(time = paste(Sys.Date(), time),
>time = as.POSIXct(time)) %>%
> select(time, y1, y2) %>%
> # reshape to long format
> pivot_longer(-time, names_to = "y") %>%
> # now plot
> ggplot(aes(time, value, color = y)) +
> geom_line() +
> geom_point() +
> scale_color_manual(values = c("orange", "skyblue")) +
> # make datetime labels
> scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
> theme_bw()
>
>
> Hope this helps,
>
> Rui Barradas
>
> [[alternative HTML version deleted]]
>
> __
> 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.

__
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.


Re: [R] Need help plotting

2022-09-23 Thread DFP
Do I need that read.table if the tst dataframe already exists in my 
system?  If so, why?

--

Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are
pivotting columnns named y1 and y2, why not name the result just y?


pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
    mutate(time = paste(Sys.Date(), time),
   time = as.POSIXct(time)) %>%
    select(time, y1, y2) %>%
    # reshape to long format
    pivot_longer(-time, names_to = "y") %>%
    # now plot
    ggplot(aes(time, value, color = y)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


Hope this helps,

Rui Barradas

[[alternative HTML version deleted]]

__
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.


Re: [R] Need help plotting

2022-09-22 Thread DFP
That worked, and helped my understanding.  Thank you.



Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are
pivotting columnns named y1 and y2, why not name the result just y?


pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
    mutate(time = paste(Sys.Date(), time),
   time = as.POSIXct(time)) %>%
    select(time, y1, y2) %>%
    # reshape to long format
    pivot_longer(-time, names_to = "y") %>%
    # now plot
    ggplot(aes(time, value, color = y)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


Hope this helps,

Rui Barradas

[[alternative HTML version deleted]]

__
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.


Re: [R] Need help plotting

2022-09-22 Thread Rui Barradas

No you don't! I do!
I don't have tst on my system.

Rui Barradas

Às 22:11 de 22/09/2022, DFP escreveu:
Do I need that read.table if the tst dataframe already exists in my 
system?  If so, why?


--

Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are
pivotting columnns named y1 and y2, why not name the result just y?


pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
    mutate(time = paste(Sys.Date(), time),
   time = as.POSIXct(time)) %>%
    select(time, y1, y2) %>%
    # reshape to long format
    pivot_longer(-time, names_to = "y") %>%
    # now plot
    ggplot(aes(time, value, color = y)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


Hope this helps,

Rui Barradas



__
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.


Re: [R] Need help plotting

2022-09-22 Thread Rui Barradas

Hello,

You have to load the packages involved:


library(dplyr)
library(tidyr)
library(ggplot2)


then run the full sequence. Though this is not important, if you are 
pivotting columnns named y1 and y2, why not name the result just y?



pivot_longer(-time, names_to = "y")


And here is complete code, runs in a fresh R session.


tst  <- read.table(text = "
time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19
", header = TRUE)

library(dplyr)
library(tidyr)
library(ggplot2)

tst %>%
  mutate(time = paste(Sys.Date(), time),
 time = as.POSIXct(time)) %>%
  select(time, y1, y2) %>%
  # reshape to long format
  pivot_longer(-time, names_to = "y") %>%
  # now plot
  ggplot(aes(time, value, color = y)) +
  geom_line() +
  geom_point() +
  scale_color_manual(values = c("orange", "skyblue")) +
  # make datetime labels
  scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
  theme_bw()


Hope this helps,

Rui Barradas

Às 20:40 de 22/09/2022, DFP escreveu:
I'm trying to do as you suggest, but I'm not understanding what I need 
to do.  I asked what the line pivot_longer(-time, names_to = "y1") would 
do if applied to this df:


 > tst
     time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19

I tried to run these lines and then look at tst, but this is what I get:

 > tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1")
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

   could not find function "%>%"

How can I learn what the pivot_longer has done to tst?

Darn it--Now I try to run the whole sequence that Rui suggested--it 
worked before--and now I get this:


 > tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1") %>%
+    # now plot
+    ggplot(aes(time, value, color = y1)) +
+    geom_line() +
+    geom_point() +
+    scale_color_manual(values = c("orange", "skyblue")) +
+    # make datetime labels
+    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
+    theme_bw()
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

   could not find function "%>%"
 >

What should I try next?



__
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.


Re: [R] Need help plotting

2022-09-22 Thread DFP
I'm trying to do as you suggest, but I'm not understanding what I need 
to do.  I asked what the line pivot_longer(-time, names_to = "y1") would 
do if applied to this df:


> tst
    time y1 y2
1  18:55 30 19
2  18:56 30 19
3  18:57 29 19
4  18:58 31 19
5  18:59 28 19
6  19:00 28 19
7  19:01 28 19
8  19:02 28 19
9  19:03 28 19
10 19:04 28 19
11 19:05 29 19

I tried to run these lines and then look at tst, but this is what I get:

> tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1")
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

  could not find function "%>%"

How can I learn what the pivot_longer has done to tst?

Darn it--Now I try to run the whole sequence that Rui suggested--it 
worked before--and now I get this:


> tst %>%
+    mutate(time = paste(Sys.Date(), time),
+  time = as.POSIXct(time)) %>%
+    select(time, y1,y2) %>%
+    # reshape to long format
+    pivot_longer(-time, names_to = "y1") %>%
+    # now plot
+    ggplot(aes(time, value, color = y1)) +
+    geom_line() +
+    geom_point() +
+    scale_color_manual(values = c("orange", "skyblue")) +
+    # make datetime labels
+    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
+    theme_bw()
Error in tst %>% mutate(time = paste(Sys.Date(), time), time = 
as.POSIXct(time)) %>%  :

  could not find function "%>%"
>

What should I try next?

__
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.


Re: [R] Need help plotting

2022-09-21 Thread Rui Barradas

Hello,

This type of problems generally has to do with reshaping the data. The 
format should be the long format and the data is in wide format.


Inline.

Às 23:35 de 21/09/2022, DFP escreveu:
As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:


# reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%

-

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
    mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime)) %>%
    select(Dtime, DNO2, MNO2) %>%
    # reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%



After selecting only the columns Dtime and *NO2 you need to reshape the 
data to long format. Some ways of telling pivot_longer what are the 
columns to become one are


 - explicitly writing all columns to be pivotted;
 - with negative indexing, all others will be put under the new name "NO2";
 - with a selection function such as ends_with("NO2"). This is probably 
more readable code if you return to it some time from now.



pivot_longer(ends_with("NO2"), names_to = "NO2") %>%


With data in the long format map column NO2 to the color aesthetic and 
ggplot will automatically understand that you have 2 groups, DNO2 and 
MNO2, and plot 2 lines and 2 groups of points (one for each color) .


Hope this helps,

Rui Barradas



    # now plot
    ggplot(aes(Dtime, value, color = NO2)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()




__
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.


Re: [R] Need help plotting

2022-09-21 Thread Ebert,Timothy Aaron
Yes, but if you want to learn R (or relearn R) it would be better for you to 
decompress the code.
You know what b looks like so add the next step. If you want to be able to see 
the original then save the output to another data frame.
New_df <- b %>%
mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime))

What do you have now?
Then add the next pipe %>% and code until the next %>%. 
When you look at the dataframe after reshape() it will be very obvious, though 
if you still have questions please ask.

Tim

-Original Message-
From: R-help  On Behalf Of DFP
Sent: Wednesday, September 21, 2022 6:35 PM
To: Rui Barradas ; r-help@r-project.org
Subject: Re: [R] Need help plotting

[External Email]

As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:

# reshape to long format
pivot_longer(-Dtime, names_to = "NO2") %>%

-

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime)) %>%
select(Dtime, DNO2, MNO2) %>%
# reshape to long format
pivot_longer(-Dtime, names_to = "NO2") %>%
# now plot
ggplot(aes(Dtime, value, color = NO2)) +
geom_line() +
geom_point() +
scale_color_manual(values = c("orange", "skyblue")) +
# make datetime labels
scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
theme_bw()


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C2e922af564854b594aae08da9c21a172%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637993965506049641%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=gnPZJIDTjVr8cv9s3foPjzYYUXWYX5Y18%2FLRKQpXyp4%3Dreserved=0
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C2e922af564854b594aae08da9c21a172%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637993965506049641%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=aLDvzRXPm3MSdulLOCbKDUSL59bO3RvhwAAkGl%2B%2BJ8M%3Dreserved=0
and provide commented, minimal, self-contained, reproducible code.

__
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.


Re: [R] Need help plotting

2022-09-21 Thread DFP
As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:

# reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%

-

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
    mutate(Dtime = paste(Sys.Date(), Dtime),
  Dtime = as.POSIXct(Dtime)) %>%
    select(Dtime, DNO2, MNO2) %>%
    # reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%
    # now plot
    ggplot(aes(Dtime, value, color = NO2)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


[[alternative HTML version deleted]]

__
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.


[R] Need help plotting

2022-09-21 Thread DFP
Thank you for the ideas below.  That did work.  I thought I had tried 
"10 mins" before, but maybe I used just 10 min.

===

Yes, you can have date_breaks = "n mins" where n is any integer.

date_breaks = "15 mins"
date_breaks = "30 mins"
date_breaks = "1 hour"   # or "1 hours", plural

The only way I know is to try different values until you find one suitable.


[[alternative HTML version deleted]]

__
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.


Re: [R] Need help plotting

2022-09-20 Thread Ebert,Timothy Aaron
Have you done something like this first?
install.packages("chron")

After that comes

library(chron)

and the rest of your code.

Tim
-Original Message-
From: R-help  On Behalf Of Bert Gunter
Sent: Tuesday, September 20, 2022 11:57 AM
To: Parkhurst, David 
Cc: r-help@r-project.org
Subject: Re: [R] Need help plotting

[External Email]

"Also, IU's tech support told me yesterday that if I responded to a message 
that came as plain text, my response would go out as plain text.  Is that true 
for this response, or is it in HTML?"

Nope, HTML. You need to set your email client to send in plain text. Do an 
internet search on how to do this, e.g. with "How to send plain text email for 
<>".

Also see "?download.packages" for how to get packages from an R package 
repository (though RStudio and no doubt other IDE's have an interface through 
which to do this).

Cheers,
Bert

On Tue, Sep 20, 2022 at 8:49 AM Parkhurst, David 
wrote:

> I like the looks of what you are doing here.
>
> However, this from my system:
> > library(chron)
> Error in library(chron) : there is no package called 'chron'
>
> How can I get chron?
>
> Also, IU's tech support told me yesterday that if I responded to a 
> message that came as plain text, my response would go out as plain 
> text.  Is that true for this response, or is it in HTML?
>
> From: Rui Barradas 
> Date: Tuesday, September 20, 2022 at 4:52 AM
> To: Jim Lemon , Parkhurst, David < 
> parkh...@indiana.edu>, r-help mailing list 
> Subject: Re: [R] Need help plotting
> Hello,
>
> Now with data, here are base R and ggplot2 plots.
>
>
> b <- read.table(text=
>  "Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2
> MVOCMpm10 Mpm2.5 Mpm1
>   18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00
>   21
>   18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00
>   21
>   18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00
>   21",
>header=TRUE,stringsAsFactors=FALSE)
>
>
> # This base R plot needs package chron
> library(chron)
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl
> .edu%7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e
> 1b84%7C0%7C0%7C637992863653204275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w
> LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> sdata=aiBOxqQsZI1Mc1vF3tDW5skxG7dTAw2J0ZOCvnJdJFc%3Dreserved
> =0
> PLEASE do read the posting guide
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r
> -project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%
> 7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e1b84%
> 7C0%7C0%7C637992863653204275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> sdata=ujwOnmg30fp6NUKoTk17Uev0pg2LBf0i8qvUtM%2F%2Fjvk%3Dreserved=
> 0 and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637992863653204275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=aiBOxqQsZI1Mc1vF3tDW5skxG7dTAw2J0ZOCvnJdJFc%3Dreserved=0
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C8fab207eca574151439308da9b2115b3%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637992863653360508%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=dFIosQzsmHgaofIKXLjVlEOcHUSlSpchBhyr%2BMMKJiU%3Dreserved=0
and provide commented, minimal, self-contained, reproducible code.

__
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.


Re: [R] Need help plotting

2022-09-20 Thread Bert Gunter
"Also, IU’s tech support told me yesterday that if I responded to a message
that came as plain text, my response would go out as plain text.  Is that
true for this response, or is it in HTML?"

Nope, HTML. You need to set your email client to send in plain text. Do an
internet search on how to do this, e.g. with "How to send plain text email
for <>".

Also see "?download.packages" for how to get packages from an R package
repository (though RStudio and no doubt other IDE's have an interface
through which to do this).

Cheers,
Bert

On Tue, Sep 20, 2022 at 8:49 AM Parkhurst, David 
wrote:

> I like the looks of what you are doing here.
>
> However, this from my system:
> > library(chron)
> Error in library(chron) : there is no package called ‘chron’
>
> How can I get chron?
>
> Also, IU’s tech support told me yesterday that if I responded to a message
> that came as plain text, my response would go out as plain text.  Is that
> true for this response, or is it in HTML?
>
> From: Rui Barradas 
> Date: Tuesday, September 20, 2022 at 4:52 AM
> To: Jim Lemon , Parkhurst, David <
> parkh...@indiana.edu>, r-help mailing list 
> Subject: Re: [R] Need help plotting
> Hello,
>
> Now with data, here are base R and ggplot2 plots.
>
>
> b <- read.table(text=
>  "Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2
> MVOCMpm10 Mpm2.5 Mpm1
>   18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00
>   21
>   18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00
>   21
>   18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00
>   21",
>header=TRUE,stringsAsFactors=FALSE)
>
>
> # This base R plot needs package chron
> library(chron)
>
>
> [[alternative HTML version deleted]]
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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.


Re: [R] Need help plotting

2022-09-20 Thread Parkhurst, David
I like the looks of what you are doing here.

However, this from my system:
> library(chron)
Error in library(chron) : there is no package called �chron�

How can I get chron?

Also, IU�s tech support told me yesterday that if I responded to a message that 
came as plain text, my response would go out as plain text.  Is that true for 
this response, or is it in HTML?

From: Rui Barradas 
Date: Tuesday, September 20, 2022 at 4:52 AM
To: Jim Lemon , Parkhurst, David , 
r-help mailing list 
Subject: Re: [R] Need help plotting
Hello,

Now with data, here are base R and ggplot2 plots.


b <- read.table(text=
 "Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2
MVOCMpm10 Mpm2.5 Mpm1
  18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00
  21
  18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00
  21
  18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00
  21",
   header=TRUE,stringsAsFactors=FALSE)


# This base R plot needs package chron
library(chron)


[[alternative HTML version deleted]]

__
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.


Re: [R] Need help plotting

2022-09-20 Thread Rui Barradas

Hello,

Now with data, here are base R and ggplot2 plots.


b <- read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 
MVOCMpm10 Mpm2.5 Mpm1
 18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00 
 21
 18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00 
 21
 18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00 
 21",

  header=TRUE,stringsAsFactors=FALSE)


# This base R plot needs package chron
library(chron)

# first make a real time class column
b$Dtime2 <- paste(b$Dtime, "00", sep = ":")
b$Dtime2 <- as.times(b$Dtime2)

# get the plot height and make room for
# the legend by adding 2 to y max
ylim <- range(unlist(b[c("DNO2", "MNO2")])) + c(0, 2)

# now plot one line
plot(DNO2 ~ Dtime2, b, type = "b", col = "orange", ylim = ylim)
# add the second line
points(MNO2 ~ Dtime2, b, type = "b", col = "skyblue")
# and the horizontal legend at the top center
legend("top", legend = c("DNO2", "MNO2"), horiz = TRUE,
   lty = "solid", col = c("orange", "skyblue"))


#---

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
  mutate(Dtime = paste(Sys.Date(), Dtime),
Dtime = as.POSIXct(Dtime)) %>%
  select(Dtime, DNO2, MNO2) %>%
  # reshape to long format
  pivot_longer(-Dtime, names_to = "NO2") %>%
  # now plot
  ggplot(aes(Dtime, value, color = NO2)) +
  geom_line() +
  geom_point() +
  scale_color_manual(values = c("orange", "skyblue")) +
  # make datetime labels
  scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
  theme_bw()


Hope this helps,

Rui Barradas


Às 08:37 de 20/09/2022, Jim Lemon escreveu:

Hi David,
I'm back home again. Try this:

b<-read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 MVOCMpm10 Mpm2.5 Mpm1
  18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00  21
  18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00  21
  18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00  2
1",
  header=TRUE,stringsAsFactors=FALSE)
b$POSIXtime<-strptime(paste("2022-09-20",b$Dtime),"%Y-%m-%d %H:%M")
png("DFPNO2.png")
plot(b$POSIXtime,b$DNO2,type="b",main="NO2 readings (2022-09-20)",
  xlab="Date/time",ylab="NO2",ylim=range(c(b$DNO2,b$MNO2)),
  pch=19,col="red")
  points(b$POSIXtime,b$MNO2,type="b",pch=19,col="blue")
  legend("center",legend=c("DNO2","MNO2"),pch=19,col=c("red","blue"))
dev.off()

If you have more than one day, it will show up on the x axis. You can
also format the tick labels if you want the full dates for only one
day.

Jim

PS thanks Avi

On Tue, Sep 20, 2022 at 4:49 PM Parkhurst, David  wrote:


Thank you.

DFP (iPad)


On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:

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  On Behalf Of Parkhurst, David
Sent: Sunday, September 18, 2022 4:27 PM
To: r-help@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]]


__
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.

__
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

Re: [R] Need help plotting

2022-09-20 Thread Jim Lemon
Hi David,
I'm back home again. Try this:

b<-read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 MVOCMpm10 Mpm2.5 Mpm1
 18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00  21
 18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00  21
 18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00  21",
 header=TRUE,stringsAsFactors=FALSE)
b$POSIXtime<-strptime(paste("2022-09-20",b$Dtime),"%Y-%m-%d %H:%M")
png("DFPNO2.png")
plot(b$POSIXtime,b$DNO2,type="b",main="NO2 readings (2022-09-20)",
 xlab="Date/time",ylab="NO2",ylim=range(c(b$DNO2,b$MNO2)),
 pch=19,col="red")
 points(b$POSIXtime,b$MNO2,type="b",pch=19,col="blue")
 legend("center",legend=c("DNO2","MNO2"),pch=19,col=c("red","blue"))
dev.off()

If you have more than one day, it will show up on the x axis. You can
also format the tick labels if you want the full dates for only one
day.

Jim

PS thanks Avi

On Tue, Sep 20, 2022 at 4:49 PM Parkhurst, David  wrote:
>
> Thank you.
>
> DFP (iPad)
>
> > On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:
> >
> > 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  On Behalf Of Parkhurst, David
> > Sent: Sunday, September 18, 2022 4:27 PM
> > To: r-help@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]]
> >
> __
> 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.
__
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.


Re: [R] Need help plotting

2022-09-20 Thread Parkhurst, David
Thank you.

DFP (iPad)

> On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:
> 
> 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  On Behalf Of Parkhurst, David
> Sent: Sunday, September 18, 2022 4:27 PM
> To: r-help@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]]
> 
__
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.


Re: [R] Need help plotting

2022-09-19 Thread Jim Lemon
Hi David,
All I got was the rather cryptic "DFP (iPad)" below your message.
Whatever format you used for the data was blocked by the R-help mail
server. Try this command in your R session:

dput(test)

and cut and paste the output into your email. That should do it.

Jim

On Tue, Sep 20, 2022 at 7:41 AM Parkhurst, David  wrote:
>
> I just sent a subset of the data, with a dataframe called test.  Can you see 
> that?  It may not have been approved by the moderator yet.
>
> DFP (iPad)
>
> > On Sep 19, 2022, at 5:29 PM, Jim Lemon  wrote:
> >
> > 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  
> >> 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@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.

__
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.


Re: [R] Need help plotting

2022-09-19 Thread Jim Lemon
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  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@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.

__
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.


Re: [R] Need help plotting

2022-09-19 Thread Ebert,Timothy Aaron
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  On Behalf Of Parkhurst, David
Sent: Sunday, September 18, 2022 4:27 PM
To: r-help@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]]

__
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.


Re: [R] Need help plotting

2022-09-19 Thread Bert Gunter
See ?date-time and/or ?strptime for how to convert what I presume is
character data in your datetime column to a POSIXct object. (you may first
need to convert from a factor to character with as.character() ). Then
follow Tim's prescription for ggplot or see ?axis.Date (especially the
examples) for how to do it with base R plots.

Cheers,
Bert

On Mon, Sep 19, 2022 at 5:15 AM Ebert,Timothy Aaron  wrote:

> 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  On Behalf Of Parkhurst, David
> Sent: Sunday, September 18, 2022 4:27 PM
> To: r-help@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]]
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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.


Re: [R] Need help plotting

2022-09-19 Thread Ebert,Timothy Aaron
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  On Behalf Of Parkhurst, David
Sent: Sunday, September 18, 2022 4:27 PM
To: r-help@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]]

__
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.


[R] Need help plotting

2022-09-19 Thread Parkhurst, David
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@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.


Re: [R] Need Help Plotting Line for multiple linear regression

2013-02-14 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Craig O'Connell
 Sent: Wednesday, February 13, 2013 11:03 PM
 To: r-help@r-project.org
 Subject: [R] Need Help Plotting Line for multiple linear regression
 
 Hello,
 
 My name is Craig and I need help plotting a line for a multiple
 linear regression in R.
 
 Here is my sample data (filename:  convis.txt)
 
 Output of convis.txt is (vis and density being predictors of either
 avoidance or entrance):
 
vis den  avoid entrance
 1   10   1 0.   0.
 2   10   3 0.8750   0.
 38   3 0.8180   0.0300
 48   3 0.6670   0.0667
 58   1 0.2110   0.
 66   1 0.2500   0.
 7   10   1 0.3000   0.
 8   10   1 0.1050   0.
 98   1 0.7000   0.1000
 10   3   5 0.1176   0.0588
 11   3   5 0.3077   0.1150
 12   3   9 0.9090   0.0900
 13   3   7 0.7778   0.1110
 14   3   5 0.5560   0.1110
 15   3   1 0.5710   0.
 16   3   4 0.5710   0.
 
 In order to do the multiple regression, I used the following coding:
 
 
 double=read.table(convis.txt,header=TRUE)
 attach(double)
 double
 stem(vis)
 stem(den)
 stem(avoid)
 stem(entrance)
 plot(entrance,vis*den)  *as means to see how the interaction

This is not an interaction, you just multiply vis and den and plot entrance on 
x axis and vis*den on y axis, so basically you want to model vis*den by 
entrance.

 between
 visibility and density may impact entrance behaviors
 model6=lm(entrance~vis*den)

This model is oposite of what you plotted.

 model6
 summary(model6)
 *abline(model6)  *Here is the issue as I used this for my simple
 linear
 regression technique, but do not know what to use for a multiple
 regression*

You seem to not understand how the multiple regression output and abline works.

Based on what you want you can do

plot(vis*den, entrance)
model6 - lm(entrance~I(vis*den))
abline(model6)

however your model will have only intercept and one coefficient for variable 
x=vis*den

If you want to have separate coefficients for vis ***and*** den and their 
interaction you can use 

model6=lm(entrance~vis*den)

but in this case resulting coefficients are Intercept, vis, den and interaction 
between vis and den. In that case beside of other procedures for model 
evaluation you can do.

plot(entrance, fitted(model6))
abline(0,1)

Regards
Petr


 
 If anybody can provide some feedback on this, it would be greatly
 appreciated.
 
 Kind Regards,
 
 Craig
 
 --
 
 Craig O'Connell
 University of Massachusetts Dartmouth
 Marine Biologist
 www.youtube.com/craigpoconnell
 craigosea.blogspot.com
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 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.

__
R-help@r-project.org mailing list
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.


Re: [R] Need Help Plotting Line for multiple linear regression

2013-02-14 Thread Greg Snow
The abline function works fine for simple linear regression because there
is only 1 line, but with multiple linear regression there are an infinite
number of lines and you need to decide which to plot (or find a way to plot
t he plane/hyperplane/surface/etc.).

One option is to use the Predict.Plot and TkPredict functions in the
TeachingDemos package.  These will plot the relationship between the
response and 1 of the predictors conditioned on values of the other
predictors.


On Wed, Feb 13, 2013 at 3:02 PM, Craig O'Connell
craigpoconn...@gmail.comwrote:

 Hello,

 My name is Craig and I need help plotting a line for a multiple linear
 regression in R.

 Here is my sample data (filename:  convis.txt)

 Output of convis.txt is (vis and density being predictors of either
 avoidance or entrance):

vis den  avoid entrance
 1   10   1 0.   0.
 2   10   3 0.8750   0.
 38   3 0.8180   0.0300
 48   3 0.6670   0.0667
 58   1 0.2110   0.
 66   1 0.2500   0.
 7   10   1 0.3000   0.
 8   10   1 0.1050   0.
 98   1 0.7000   0.1000
 10   3   5 0.1176   0.0588
 11   3   5 0.3077   0.1150
 12   3   9 0.9090   0.0900
 13   3   7 0.7778   0.1110
 14   3   5 0.5560   0.1110
 15   3   1 0.5710   0.
 16   3   4 0.5710   0.

 In order to do the multiple regression, I used the following coding:


 double=read.table(convis.txt,header=TRUE)
 attach(double)
 double
 stem(vis)
 stem(den)
 stem(avoid)
 stem(entrance)
 plot(entrance,vis*den)  *as means to see how the interaction between
 visibility and density may impact entrance behaviors
 model6=lm(entrance~vis*den)
 model6
 summary(model6)
 *abline(model6)  *Here is the issue as I used this for my simple linear
 regression technique, but do not know what to use for a multiple
 regression*

 If anybody can provide some feedback on this, it would be greatly
 appreciated.

 Kind Regards,

 Craig

 --
 
 Craig O'Connell
 University of Massachusetts Dartmouth
 Marine Biologist
 www.youtube.com/craigpoconnell
 craigosea.blogspot.com

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 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.




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] Need Help Plotting Line for multiple linear regression

2013-02-13 Thread Craig O'Connell
Hello,

My name is Craig and I need help plotting a line for a multiple linear
regression in R.

Here is my sample data (filename:  convis.txt)

Output of convis.txt is (vis and density being predictors of either
avoidance or entrance):

   vis den  avoid entrance
1   10   1 0.   0.
2   10   3 0.8750   0.
38   3 0.8180   0.0300
48   3 0.6670   0.0667
58   1 0.2110   0.
66   1 0.2500   0.
7   10   1 0.3000   0.
8   10   1 0.1050   0.
98   1 0.7000   0.1000
10   3   5 0.1176   0.0588
11   3   5 0.3077   0.1150
12   3   9 0.9090   0.0900
13   3   7 0.7778   0.1110
14   3   5 0.5560   0.1110
15   3   1 0.5710   0.
16   3   4 0.5710   0.

In order to do the multiple regression, I used the following coding:


double=read.table(convis.txt,header=TRUE)
attach(double)
double
stem(vis)
stem(den)
stem(avoid)
stem(entrance)
plot(entrance,vis*den)  *as means to see how the interaction between
visibility and density may impact entrance behaviors
model6=lm(entrance~vis*den)
model6
summary(model6)
*abline(model6)  *Here is the issue as I used this for my simple linear
regression technique, but do not know what to use for a multiple regression*

If anybody can provide some feedback on this, it would be greatly
appreciated.

Kind Regards,

Craig

-- 

Craig O'Connell
University of Massachusetts Dartmouth
Marine Biologist
www.youtube.com/craigpoconnell
craigosea.blogspot.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.