Thread for students in Gov 50 to post reprexes. Please do not answer them!

I'm running into an error in Recitation 3.

library(tidyverse)
library(gapminder)

gapminder %>%
  filter(country == "Afghanistan") %>%
  ggplot(aes(x = year, y =lifeExp)) %>%
  geom_point()
#> Error: `mapping` must be created by `aes()`
#> Did you use %>% instead of +?
library(dslabs)
library(tidyverse)

data("murders")

murders %>%
  mutate(rate = 1e5 * (totale / population))
#> Error: Problem with `mutate()` input `rate`.
#> x object 'totale' not found
#> ℹ Input `rate` is `1e+05 * (totale/population)`.

Help! I don't know why the new column is being created.

library(tidyverse)
library(gapminder)

gapminder %>% 
  filter(country == "Afghanistan") %>% 
  ggplot(aes(x = year, y = lifeExp)) +
  geom_point()

test

gapminder %>%
  filter(country == "Afghanistan") %>%
  ggplot(aes(x = year, y = lifeExp)) +
  geom_point()
#> Error in gapminder %>% filter(country == "Afghanistan") %>% ggplot(aes(x = year, : could not find function "%>%"```
sdfsdhksd
#> Error in eval(expr, envir, enclos): object 'sdfsdhksd' not found

Here's a fake problem:

library(tidyverse)
library(stringr)
library(gt)
library(readxl)
library(janitor)


sep_joined_sliced <- sep_joined %>% 
  slice(1:5, 412:416) %>% 
  mutate(Change7 = ifelse(u_grad_diff > 0, "Increase", "Decrease")) %>% 
  mutate(u_grad_diff_abs = abs(u_grad_diff))
#> Error in eval(lhs, parent, parent): object 'sep_joined' not found

sep_joined_sliced %>% 
  ggplot(aes(x = reorder(title, u_grad_diff_abs), y = u_grad_diff_abs,
             fill = Change)) +
    geom_col() +
    labs(x = "Course Number", y = "Change in Enrollment",
         caption = "Source: Harvard Registrar's Office") +
    coord_flip() +
    ggtitle("Classes with Five Biggest Increases and Five 
            \n Biggest Decreases in Enrollment, Sep 1st - Sep 22nd") +
    theme_minimal() 
#> Error in eval(lhs, parent, parent): object 'sep_joined_sliced' not found
punch(hebfa)
#> Error in punch(hebfa): could not find function "punch"
mutat(input = )
#> Error in mutat(input = ): could not find function "mutat"
mutat(input = )
#> Error in mutat(input = ): could not find function "mutat"

Created on 2020-09-24 by the reprex package (v0.3.0)

Test

library(tidyverse)
library(gapminder)

gapminder %>%
  filter(country == "Afghanistan") %>%
  ggplot(aes(year, lifeExp)) %>%
  geom_point()
#> Error: `mapping` must be created by `aes()`
#> Did you use %>% instead of +?
library(tidyverse)
library(gapminder)

gapminder %>%
  filter(country == "Afghanistan") %>%
  ggplot(aes(x = year, y = lifeExp)) %>%
  geom_point()
#> Error: `mapping` must be created by `aes()`
#> Did you use %>% instead of +?
x <- 5
y <- 2
x + y
#> [1] 7
x <- 3
y <- 5

Practice for recitation

knitr::opts_chunk$set(echo = TRUE)
library(reprex)
library(dslabs)
library(tidyverse)

data("murders")

murders %>% 
  mutate(rate = total/population * 100000)
  
library(tidyverse)
library(reprex)
library(dslabs)

data("murders")

murders %>% 
  group_by( region) %>% 
  summarise(whole_region = sum("total"))
#> Error: Problem with `summarise()` input `whole_region`.
#> x invalid 'type' (character) of argument
#> ℹ Input `whole_region` is `sum("total")`.
#> ℹ The error occurred in group 1: region = "Northeast".

Created on 2020-09-24 by the reprex package (v0.3.0)

library(reprex)
library(tidyverse)
library(dslabs)

data("murders")

murder %>% mutate(rate = total/population * 100000)
#> Error in eval(lhs, parent, parent): object 'murder' not found

Created on 2020-09-24 by the reprex package (v0.3.0)

library(reprex)
library(dslabs)
library(tidyverse)

data("murders")

murders %>%
  mutate(rate = totale/population * 10e5)
#> Error: Problem with `mutate()` input `rate`.
#> x object 'totale' not found
#> ℹ Input `rate` is `totale/population * 1e+06`.

I am trying to calculate the murder rate for each of the 50 states per one hundred thousand people

library(reprex)
library(dslabs)
library(tidyverse)

data("murders")

murders %>%
mutate(rate = total/populatios * 10e5)
#> Error: Problem with mutate() input rate.
#> x object 'populatios' not found
#> :information_source: Input rate is total/populatios * 1e+06.

I do not know why my columns aren't being created through mutate. Help!

library(reprex)
library(dslabs)
library(tidyverse)

data("murders")
murders %>%
  ggplot(aes(x = state, y = population)) %>%
  geom_col()
#> Error: `mapping` must be created by `aes()`
#> Did you use %>% instead of +?

Created on 2020-09-24 by the reprex package (v0.3.0)

I was trying to create a column for the rate of murders but I'm getting this weird code. Here is my reprex!

library(reprex)
library(dslabs)
library(tidyverse)

# Load data from dslabs (murder stats for all 50 states).

data("murders")

murders %>%
  mutate(rate = tota/population*1e5)
#> Error: Problem with `mutate()` input `rate`.
#> x object 'tota' not found
#> ℹ Input `rate` is `tota/population * 1e+05`.