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

Do not answer the questions in this thread! This is a location for students in my Gov 50 class to practice posting a reprex.

5 Likes

This is a test!

x <- list(nums = c(10, 12, 11.5), ids = c("H4", "H6", "H1"))
#install.packages("reprex")
library(reprex)
#install.packages("dslabs")
library(tidyverse)
  library(dslabs)
data("murders")
  murders %>%
mutate(rate= (total/popultion)*100000)
#> Error: Problem with `mutate()` input `rate`.
#> x object 'popultion' not found
#> ℹ Input `rate` is `(total/popultion) * 1e+05`.

Was attempting to create a new column named "rate" of murders per 100,000 people.

#install.packages("reprex")
library(reprex)
#install.packages("dslabs")
library(dslabs)
library(tidyverse)
data("murders")
View(murders)
#> Error in check_for_XQuartz(): X11 library is missing: install XQuartz from xquartz.macosforge.org
murders %>% 
  mutate(rate = (total/poplation)*10e5)
#> Error: Problem with `mutate()` input `rate`.
#> x object 'poplation' not found
#> ℹ Input `rate` is `(total/poplation) * 1e+06`.

Was trying to create a "rate" column from my dataset but it didn't work :frowning:

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

I was trying to create a column named "rate" containing the number of murders per 100,000.

x <- c(2,4,6)
x + 7
#> [1]  9 11 13

Practice making a repress during recitation.

(y <- 1:4)
#> [1] 1 2 3 4
mean(Y)
#> Error in mean(Y): object 'Y' not found
(y <- 1:4)
#> [1] 1 2 3 4
mean(Y)
#> Error in mean(Y): object 'Y' not found
(y <- 1:4)
#> [1] 1 2 3 4
mean(Y)
#> Error in mean(Y): object 'Y' not found
 x <- c(3,4,5)  
      x + 2
#> [1] 5 6 7

Testing

test<- "Have a Great Day"
library(tidyverse)
library(PPBDS.data)
sps %>%
ggplot(x = education, y = health_exp_3m) +
  geom_point()
#> Error: geom_point requires the following missing aesthetics: x and y
library(tidyverse)
library(PPBDS.data)
sps %>%
  ggplot(x = education, y = health_exp_3m) +
  geom_point()
#> Error: geom_point requires the following missing aesthetics: x and y
## you can put any code here!
library(tidyverse)

diamonds %>% 
  slice(1:5) %>% 
  select(depth, cut, appeal, clarity)
#> Error: Can't subset columns that don't exist.
#> x Column `appeal` doesn't exist.

#help

## you can put any code here!
library(tidyverse)

diamonds %>% 
  slice(1:5) %>% 
  select(depth, cut, appeal, clarity)
#> Error: Can't subset columns that don't exist.
#> x Column `appeal` doesn't exist
## you can put any code here!
library(tidyverse)

diamonds %>% 
  slice(1:5) %>% 
  select(depth, cut, appeal, clarity) %>%
  group_by(thing)
#> Error: Can't subset columns that don't exist.
#> x Column `appeal` doesn't exist.
library(tidyverse)
library(reprex)
library(dslabs)
data("murders")
murders
#>                   state abb        region population total
#> 1               Alabama  AL         South    4779736   135
#> 2                Alaska  AK          West     710231    19
#> 3               Arizona  AZ          West    6392017   232
#> 4              Arkansas  AR         South    2915918    93
#> 5            California  CA          West   37253956  1257
#> 6              Colorado  CO          West    5029196    65
#> 7           Connecticut  CT     Northeast    3574097    97
#> 8              Delaware  DE         South     897934    38
#> 9  District of Columbia  DC         South     601723    99
#> 10              Florida  FL         South   19687653   669
#> 11              Georgia  GA         South    9920000   376
#> 12               Hawaii  HI          West    1360301     7
#> 13                Idaho  ID          West    1567582    12
#> 14             Illinois  IL North Central   12830632   364
#> 15              Indiana  IN North Central    6483802   142
#> 16                 Iowa  IA North Central    3046355    21
#> 17               Kansas  KS North Central    2853118    63
#> 18             Kentucky  KY         South    4339367   116
#> 19            Louisiana  LA         South    4533372   351
#> 20                Maine  ME     Northeast    1328361    11
#> 21             Maryland  MD         South    5773552   293
#> 22        Massachusetts  MA     Northeast    6547629   118
#> 23             Michigan  MI North Central    9883640   413
#> 24            Minnesota  MN North Central    5303925    53
#> 25          Mississippi  MS         South    2967297   120
#> 26             Missouri  MO North Central    5988927   321
#> 27              Montana  MT          West     989415    12
#> 28             Nebraska  NE North Central    1826341    32
#> 29               Nevada  NV          West    2700551    84
#> 30        New Hampshire  NH     Northeast    1316470     5
#> 31           New Jersey  NJ     Northeast    8791894   246
#> 32           New Mexico  NM          West    2059179    67
#> 33             New York  NY     Northeast   19378102   517
#> 34       North Carolina  NC         South    9535483   286
#> 35         North Dakota  ND North Central     672591     4
#> 36                 Ohio  OH North Central   11536504   310
#> 37             Oklahoma  OK         South    3751351   111
#> 38               Oregon  OR          West    3831074    36
#> 39         Pennsylvania  PA     Northeast   12702379   457
#> 40         Rhode Island  RI     Northeast    1052567    16
#> 41       South Carolina  SC         South    4625364   207
#> 42         South Dakota  SD North Central     814180     8
#> 43            Tennessee  TN         South    6346105   219
#> 44                Texas  TX         South   25145561   805
#> 45                 Utah  UT          West    2763885    22
#> 46              Vermont  VT     Northeast     625741     2
#> 47             Virginia  VA         South    8001024   250
#> 48           Washington  WA          West    6724540    93
#> 49        West Virginia  WV         South    1852994    27
#> 50            Wisconsin  WI North Central    5686986    97
#> 51              Wyoming  WY          West     563626     5
+ arrange(murders) + head(10)
#> Error in FUN(left): invalid argument to unary operator

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

Couldn't figure out why this was generating an error!

library(tidyverse)
library(dslabs)
data("murders")
+ arrange(murders) + head(10)
#> Error in FUN(left): invalid argument to unary operator

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

Using the right tidyverse functions, but code is not working.

library(gapminder)
library(tidyverse)

# because my pipe comes from the tidyverse! two packages necessary for code to run

gapminder %>%
  filter(year = 1952)
#> Error: Problem with `filter()` input `..1`.
#> x Input `..1` is named.
#> ℹ This usually means that you've used `=` instead of `==`.
#> ℹ Did you mean `year == 1952`?
  group_by(continent) %>%
  summarize(avg_lifeExp = mean(lifeExp)) +
  ggplot(aes(x = country, y = lifeExp)) +
  geom_col()
#> Error in group_by(continent): object 'continent' not found
library(tidyverse)
library(gapminder)

gapminder %>%  
  filter(year = 1952) %>%
  group_by(continent) %>%
  summarize(avg_lifeExp = mean(lifeExp)) %>%
  ggplot(aes(x = country, y = lifeExp)) + geom_col()
#> Error: Problem with `filter()` input `..1`.
#> x Input `..1` is named.
#> ℹ This usually means that you've used `=` instead of `==`.
#> ℹ Did you mean `year == 1952`?