Question: > library(tidyr) > library(readr) > > # Load the datasets > > pols unemployment snp > pols % + separate(mon, into = c (year, month),

> library(tidyr) > library(readr) > > # Load the datasets > > pols <- read.csv("data/fivethirtyeight_datasets/pols-month.csv") > unemployment <- read.csv("data/fivethirtyeight_datasets/unemployment.csv") > snp <- read.csv("data/fivethirtyeight_datasets/snp.csv") > > pols <- pols %>% + separate(mon, into = c ("year", "month"), sep = "-") %>% + # convert month to numeric + mutate(month = as.numeric(month)) Warning: Expected 2 pieces. Additional pieces discarded in 822 rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...]. > > #Replace month number with month name > pols$month <- month.name[pols$month] > > # Remove unwanted variables > pols <- pols %>% + mutate(president = case_when( + prez_dem == 1 ~ "dem", + prez_gop == 1 ~ "gop" + )) %>% + select(-prez_dem, -prez_gop, -day) Error in `select()`: ! Can't select columns that don't exist. Column `day` doesn't exist. Run `rlang::last_trace()` to see where the error occurred. > # Load required libraries > library(tidyverse) Attaching core tidyverse packages tidyverse 2.0.0 forcats 1.0.0 purrr 1.1.0 ggplot2 3.5.2 stringr 1.5.2 lubridate 1.9.4 tibble 3.3.0 Conflicts tidyverse_conflicts() dplyr::filter() masks stats::filter() dplyr::lag() masks stats::lag() Use the conflicted package to force

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!