First, make sure you install and load the esquisse package using install.packages and library:

install.packages("esquisse")
install.packages("ggplot2")
library(esquisse)
library(ggplot2)
library(dplyr)
library(dasehr)

1.1

Try creating a plot in esquisse using the calenviroscreen data from the dasehr packaged. This dataset has a lot of variables, so first run the below code to subset it so that you’re only working with these variables: CES4.0Percentile, Asthma, and ChildrenPercLess10. We will also categorize CES4.0Percentile into three categories (high, middle, and low) to make visualization a little easier!

ces_sub <- select(calenviroscreen, c("CES4.0Percentile", "Asthma", "ChildrenPercLess10"))

ces_sub <- ces_sub %>% 
            mutate(CES4.0Perc_cat = 
              case_when(CES4.0Percentile > 75  ~ "High", 
                        CES4.0Percentile <= 75 & CES4.0Percentile >25 ~ "Middle",
                        CES4.0Percentile <= 25 ~ "Low"))
# esquisser(ces_sub)
ggplot(ces_sub) +
  aes(x = ChildrenPercLess10, y = Asthma) +
  geom_point(shape = "circle", size = 1.5, colour = "#112446") +
  theme_minimal() +
  facet_wrap(vars(CES4.0Perc_cat))
## Warning: Removed 23 rows containing missing values or values outside the scale range
## (`geom_point()`).

ggplot(ces_sub) +
  aes(x = ChildrenPercLess10, y = Asthma, colour = CES4.0Perc_cat) +
  geom_point(shape = "circle", size = 1.5) +
  scale_color_hue(direction = 1) +
  theme_minimal()
## Warning: Removed 23 rows containing missing values or values outside the scale range
## (`geom_point()`).

1.2

Click where it says “point” (may say “auto” depending on how you did the last question) on the far left side and change the plot to a different type of plot. Copy and paste the code into the chunk below. Close Esquisse and run the chunk below to generate a ggplot.

ggplot(ces_sub) +
  aes(x = ChildrenPercLess10, y = Asthma, colour = CES4.0Perc_cat) +
  geom_line(size = 0.5) +
  scale_color_hue(direction = 1) +
  theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 23 rows containing missing values or values outside the scale range
## (`geom_line()`).

Practice on Your Own!

P.1

Launch Esquisse on any selection of the following datasets we have worked with before and explore!

covid_wastewater
## # A tibble: 776,059 × 12
##    reporting_jurisdiction sample_location key_plot_id               county_names
##    <chr>                  <chr>           <chr>                     <chr>       
##  1 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  2 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  3 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  4 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  5 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  6 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  7 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  8 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
##  9 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
## 10 Missouri               Treatment plant NWSS_mo_259_Treatment pl… Barry,Lawre…
## # ℹ 776,049 more rows
## # ℹ 8 more variables: population_served <dbl>, date_start <chr>,
## #   date_end <chr>, rna_pct_change_15d <dbl>, pos_PCR_prop_15d <dbl>,
## #   percentile <dbl>, sampling_prior <chr>, first_sample_date <chr>
CO_heat_ER
## # A tibble: 2,340 × 7
##    county     rate lower95cl upper95cl visits  year gender      
##    <chr>     <dbl>     <dbl>     <dbl>  <dbl> <dbl> <chr>       
##  1 Statewide  5.64      4.70      6.59    140  2011 Female      
##  2 Statewide  7.39      6.30      8.47    183  2011 Male        
##  3 Statewide  6.51      5.80      7.23    323  2011 Both genders
##  4 Statewide  5.64      4.72      6.57    146  2012 Female      
##  5 Statewide  7.56      6.48      8.65    193  2012 Male        
##  6 Statewide  6.58      5.88      7.29    339  2012 Both genders
##  7 Statewide  4.94      4.06      5.82    124  2013 Female      
##  8 Statewide  6.72      5.72      7.72    178  2013 Male        
##  9 Statewide  5.82      5.16      6.49    302  2013 Both genders
## 10 Statewide  3.52      2.80      4.25     92  2014 Female      
## # ℹ 2,330 more rows
CO_heat_ER_byage
## # A tibble: 216 × 7
##     YEAR GENDER AGE              RATE L95CL U95CL VISITS
##    <dbl> <chr>  <chr>           <dbl> <dbl> <dbl>  <dbl>
##  1  2011 Female 0-4 years old   NA    NA    NA        NA
##  2  2011 Female 15-34 years old  5.59  3.84  7.34     39
##  3  2011 Female 35-64 years old  5.51  4.08  6.94     57
##  4  2011 Female 5-14 years old   4.43  2.48  7.30     15
##  5  2011 Female 65+ years old    6.60  3.78  9.42     21
##  6  2011 Female All ages         5.48  4.57  6.39    140
##  7  2011 Male   0-4 years old   NA    NA    NA        NA
##  8  2011 Male   15-34 years old  8.99  6.84 11.1      67
##  9  2011 Male   35-64 years old  6.17  4.66  7.68     64
## 10  2011 Male   5-14 years old   5.94  3.40  8.48     21
## # ℹ 206 more rows
CO_heat_ER_bygender
## # A tibble: 240 × 7
##    county  rate lower95cl upper95cl visits  year gender
##    <chr>  <dbl>     <dbl>     <dbl>  <dbl> <dbl> <chr> 
##  1 Adams   7.60      4.38     11.7      17  2011 Female
##  2 Adams  NA        NA        NA        NA  2012 Female
##  3 Adams   6.22      3.37      9.93     14  2013 Female
##  4 Adams  NA        NA        NA        NA  2014 Female
##  5 Adams  NA        NA        NA        NA  2015 Female
##  6 Adams   6.16      3.35      9.82     14  2016 Female
##  7 Adams   4.69      2.31      7.88     11  2017 Female
##  8 Adams   6.39      3.62      9.93     16  2018 Female
##  9 Adams   6.64      3.85     10.2      17  2019 Female
## 10 Adams  NA        NA        NA        NA  2020 Female
## # ℹ 230 more rows
yearly_co2_emissions
## # A tibble: 192 × 265
##    country `1751` `1752` `1753` `1754` `1755` `1756` `1757` `1758` `1759` `1760`
##    <chr>    <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
##  1 Afghan…     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  2 Albania     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  3 Algeria     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  4 Andorra     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  5 Angola      NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  6 Antigu…     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  7 Argent…     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  8 Armenia     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
##  9 Austra…     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
## 10 Austria     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
## # ℹ 182 more rows
## # ℹ 254 more variables: `1761` <dbl>, `1762` <dbl>, `1763` <dbl>, `1764` <dbl>,
## #   `1765` <dbl>, `1766` <dbl>, `1767` <dbl>, `1768` <dbl>, `1769` <dbl>,
## #   `1770` <dbl>, `1771` <dbl>, `1772` <dbl>, `1773` <dbl>, `1774` <dbl>,
## #   `1775` <dbl>, `1776` <dbl>, `1777` <dbl>, `1778` <dbl>, `1779` <dbl>,
## #   `1780` <dbl>, `1781` <dbl>, `1782` <dbl>, `1783` <dbl>, `1784` <dbl>,
## #   `1785` <dbl>, `1786` <dbl>, `1787` <dbl>, `1788` <dbl>, `1789` <dbl>, …
nitrate
## # A tibble: 88 × 11
##     year quarter pop_on_sampled_PWS `pop_0-3ug/L` `pop_>3-5ug/L` `pop_>5-10ug/L`
##    <dbl> <chr>                <dbl>         <dbl>          <dbl>           <dbl>
##  1  1999 Q1                  106720         67775              0              32
##  2  1999 Q2                   85541         55476              0             212
##  3  1999 Q3                  559137        319252         231186             212
##  4  1999 Q4                   26995         25969            420               0
##  5  2000 Q1                   34793          5904              0              92
##  6  2000 Q2                  184521        157396              0              32
##  7  2000 Q3                   42081         20407            345               0
##  8  2000 Q4                  407219        358828            995             412
##  9  2001 Q1                   90054         49552            150               0
## 10  2001 Q2                   83521         43633           2536              90
## # ℹ 78 more rows
## # ℹ 5 more variables: `pop_>10-20ug/L` <dbl>, `pop_>20ug/L` <dbl>,
## #   `pop_on_PWS_with_non-detect` <dbl>, pop_exposed_to_exceedances <dbl>,
## #   perc_pop_exposed_to_exceedances <dbl>
haa5
## # A tibble: 33 × 11
##    year  pop_on_sampled_PWS `pop_0-15µg/L` `pop_>15-30µg/L` `pop_>30-45µg/L`
##    <chr>              <dbl>          <dbl>            <dbl>            <dbl>
##  1 1999              367633          59550           149906           105097
##  2 2000             1197054         299306           122665           470362
##  3 2001             1228179         341227           551559           100539
##  4 2002             2344171         461360          1560551            68158
##  5 2003             2536748         973263          1296957           263403
##  6 2004             4335514        1716193          1714404           139075
##  7 2005             4100329        1670136          1711888            91667
##  8 2006             4401035        1576037          2192933           207336
##  9 2007             4726314        1771815          2063751           176017
## 10 2008             4678903        1958654          2006626           121242
## # ℹ 23 more rows
## # ℹ 6 more variables: `pop_>45-60µg/L` <dbl>, `pop_>60-75µg/L` <dbl>,
## #   `pop_>75µg/L` <dbl>, `pop_on_PWS_with_non-detects` <dbl>,
## #   pop_exposed_to_exceedances <dbl>, perc_pop_exposed_to_exceedances <dbl>
# esquisser(nitrate)