Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Functions] update lab_Dec2024 #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions modules/Functions/lab/Functions_Lab_Key.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ ces %>%

### P.3

Take your code from previous question and assign it to the variable `ces_dat`.
Take your code from previous question and assign it to the object `ces_dat`.

- Create a ggplot where the x-axis is `Asthma` and the y-axis is `PM2.5`.
- Add a boxplot (`geom_boxplot()`)
- Change the `labs()` layer so that the x-axis is "ER Visits for Asthma: PM2.5 greater than 10"

**NOTE:** You can make this code into a function! To do so, you create a function that doesn't have any inputs. Instead, just hard-code the column names into the ggplot `aes` line. The function will create this exact plot every time it is called.

```{r P.3response}
ces_dat <-
ces %>%
Expand All @@ -200,7 +202,7 @@ ces_dat <-
function(x) x > 10
))

ggplot(data = ces_dat, aes(x = `Asthma`, y = `PM2.5`)) +
ggplot(data = ces_dat, aes(x = Asthma, y = PM2.5)) +
geom_boxplot() +
labs(x = "ER Visits for Asthma: PM2.5 greater than 10")

Expand All @@ -211,7 +213,7 @@ ces_boxplot <- function() {
starts_with("PM"),
function(x) x > 10
)) %>%
ggplot(aes(x = `Asthma`, y = `PM2.5`)) +
ggplot(aes(x = Asthma, y = PM2.5)) +
geom_boxplot() +
labs(x = "ER Visits for Asthma: PM2.5 greater than 10")
}
Expand Down
Loading