Okay, I can't help much with the ggplot stuff so forget the "lty="
argument for that is base graphics. However, you may get away with
ggtitle(paste0("COVID-19 Tests in Ohio
\n(",date[length(date]),")"))+
I don't know whether the tidy* stuff handles indexing in the same way as
base R.
Jim
On Wed, Aug 19, 2020 at 12:20 PM Stephen P. Molnar
<s.molnar at sbcglobal.net> wrote:>
> Jim
>
> Thanks for your note.
>
> This is what didn't make it through:
>
> library(tidyverse)
> library(lubridate)
>
> datO <-
read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv")
> <- line 14
> datO[ ,1] <- ymd(datO[ ,1])
>
> dfO <- tibble::as_tibble(data.frame(date = datO[ ,"date"],
> positive = datO[
,"positive"],
> negative = datO[
,"negative"],
> total = datO[ ,"total"]))
>
> dfO %>%
> pivot_longer(
> cols = -date,
> names_to = "cases",
> values_to = "count"
> ) %>%
> mutate(cases = factor(cases, levels = c("positive",
"negative",
> "total"))) %>%
> ggplot(aes(date, count, color = cases)) +
> geom_line() +
> scale_color_manual(name = "Test",
> labels = c("Positive",
"Negative", "Total"),
> values = c("red", "blue",
"green")) +
> ylim(0, 2000000) +
> labs(x = "Date", y = "Number of Tests")+
> ggtitle("COVID-19 Tests in Ohio \n (8/17/20)")+ <- line
33
> theme_bw() +
> theme(axis.text.x = element_text(angle = 30, hjust = 1),
> plot.title = element_text(hjust = 0.5))
>
> Steve
>
> On 08/18/2020 07:55 PM, Jim Lemon wrote:
> > Hi Stephen,
> > I think something went amiss with your email as there are a few blank
> > lines where I think you meant to paste a code fragment. Line type is
> > specified by the "lty" argument and to stick things together
for your
> > plot title, you may want something like this:
> >
> > ..
> > main<-paste("My plot title for",dates[length(dates)]).
> > ..
> >
> > Jim
> >
> > On Wed, Aug 19, 2020 at 3:09 AM Stephen P. Molnar
> > <s.molnar at sbcglobal.net> wrote:
> >> Thanks to the kind folks on this list, this is an elegant
replacement
> >> for the clumsy R script that I that I wrote.
> >>
> >>
> >>
> >>
> >> However, I do have a few changes that I would like to make. The
problem
> >> is that while I know how to make changes in Python, I am still
bumbling
> >> around in R Code.
> >>
> >> The day-to-day changes in the data are in the cvs file downloaded
in
> >> line 11 of the code.
> >>
> >> What I would like to do is use linetype, rather than color, in
line 27.
> >>
> >> The date in the title of the plot , line 33, is the max value of
the
> >> date in in line 14 and I would like to use that rather than edit
the
> >> Script every time the date changes.
> >>
> >> I'd appreciate assistance in making these changes.
> >>
> >> Thanks in advance,.
> >>
> >> --
> >> Stephen P. Molnar, Ph.D.
> >> www.molecular-modeling.net
> >> 614.312.7528 (c)
> >> Skype: smolnar1
> >>
> >> ______________________________________________
> >> 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.
>
> --
> Stephen P. Molnar, Ph.D.
> www.molecular-modeling.net
> 614.312.7528 (c)
> Skype: smolnar1
>