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

y <- 2 + "fish"
#> Error in 2 + "fish": non-numeric argument to binary operator

library(tidyverse) library(dslabs) data("murders") # Calculate the rate of murders/state murders %>% mutate(rate = total/poplation * 100000)

library(tidyverse)
library(reprex)
library(dslabs)
murders %>%  mutate(rate = total/poplation * 100000)
#> Error: Problem with `mutate()` input `rate`.
#> x object 'poplation' not found
#> ℹ Input `rate` is `total/poplation * 1e+05`.

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

library(reprex)
library(dslabs)
data("murders")
library(tidyverse)
library(janitor)
#> 
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#> 
#>     chisq.test, fisher.test

murders %>% mutates(murder_percentage = (total / population))
#> Error in mutates(., murder_percentage = (total/population)): could not find function "mutates"

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

Using a tidyverse function but can't get it to work.

library(reprex)
library(tidyverse)
library(dslabs)
data("murders")

murders %>%
  mutates(murder_percentage = total/population)
#> Error in mutates(., murder_percentage = total/population): could not find function "mutates"

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

Help I have a bug!

library(tidyverse)
library(PPBDS.data)

shaming %>%
  group_by(does_not_exist)
#> Error: Must group by variables found in `.data`.
#> * Column `does_not_exist` is not found.
library(tidyverse)
library(PPBDS.data)
trains%>%
  select(gender, treatment)%>%
  arrange(desc(treatmint))
#> Error: arrange() failed at implicit mutate() step. 
#> x Could not create a temporary column for `..1`.
#> ℹ `..1` is `treatmint`.
``` Not sure what's going wrong!!!!!!!!!
x = "hello"
x + "bye"
#> Error in x + "bye": non-numeric argument to binary operator

Help, I have a bug!

library(tidyverse)

diamonds %>%
filter(carat = "cake")
#> Error: Problem with filter() input ..1.
#> x Input ..1 is named.
#> i This usually means that you've used = instead of ==.
#> i Did you mean carat == "cake"?

x = "hello"
x + "bye"
#> Error in x + "bye": non-numeric argument to binary operator

Help pls.

 library(tidyverse)
 library(PPBDS.data)
 
names <- c("Ben", "Daiana", "Britteny")
 
names + 2
#> Error in names + 2: non-numeric argument to binary operator
q1 <- candidates %>% 
  filter(cand_id)
#> Error in candidates %>% filter(cand_id): could not find function "%>%"
q1 <- candidates %>% 
  filter(cand_id)
#> Error in candidates %>% filter(cand_id): could not find function "%>%"

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

Need help with a bug.

library(tidyverse)
library(PPBDS.data)

shaming %>%
group_by(does_not_exist)
#> Error: Must group by variables found in .data.
#> * Column does_not_exist is not found.

library(tidyverse)
library(PPBDS.data)

shaming %>%
  group_by(does_not_exist)
#> Error: Must group by variables found in `.data`.
#> * Column `does_not_exist` is not found.
library(tidyverse)
library(fec16)
library(ggthemes)
q1 <- candidates %>%
  select(cand_name, cand_pty_affiliation, cand_office_st, cand_office) %>%
  filter(cand_pty_affiliation == c("DEM", "REP")) %>%
  arrange(cand_name) %>%
slice(1)
#> Warning in cand_pty_affiliation == c("DEM", "REP"): longer object length is not
#> a multiple of shorter object length

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

What's going on here? Why is this warning about object length being brought up? Is it bad?

filter <- nominate %>%
  mutate(born = 0)
#> Error in nominate %>% mutate(born = 0): could not find function "%>%"

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

"james" + 5 
#> Error in "james" + 5: non-numeric argument to binary operator

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

"alexa" - 2
#> Error in "alexa" - 2: non-numeric argument to binary operator

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

"alexa" - 2
#> Error in "alexa" - 2: non-numeric argument to binary operator

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