Aula4

Author

ARLAM

No ggplot2, os gráficos são construídos camada por camada (ou, layers, em inglês).

Importa dados

library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.2.3
Warning: package 'tibble' was built under R version 4.2.3
Warning: package 'dplyr' was built under R version 4.2.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)

curve<-read_excel("C:dados-diversos.xlsx", "curve")

Gráficos

curve |> 
  ggplot(aes(Irrigation, severity,
             shape = Irrigation))+
  geom_point(alpha = 0.5)

curve2 <- curve |> 
  select(day, rep, severity) |> 
  group_by(day) |> 
  summarize(sev = mean(severity))
curve2 |> 
  ggplot(aes(day, sev*100))+
  geom_line(color = "darkorange")+
  geom_point(size = 3,
             color = "darkorange")+
   scale_x_continuous(breaks = c(0,7, 14, 21, 28, 35, 42, 49, 56, 63))+
  scale_y_continuous(n.breaks = 5,
                     limits = c(0,100))+
    labs(x = "Time (days)",
         y = "Severity (%)",
         title = "My first disease progress curve",
         subtitle = "Using ggplot",
         caption = "Source: FIP 606")+
  theme_light()

ggsave("figures/myfirstggplot.png", 
       bg = "white",
       width = 4,
       height = 3)