I have this dataset of columns, one is basically a quote and the Name of the state, below is an example: `
library(tidyverse)
df <- tibble(num = c(11,12,13), quote = c("In Ohio, there are plenty of hobos","Georgia, where the peaches are peachy","Oregon, no, we did not die of dysentery"))
I want to create a column that extracts the specific state.
我在此试图:
states <- state.name
df <- df %>% mutate(state = na.omit(as.vector(str_match(quote,states)))[[1]])
Which fetches this error:
Error in `mutate()`:
ℹ In argument: `state = na.omit(as.vector(str_match(quote, states)))[[1]]`.
Caused by error in `str_match()`:
! Can t recycle `string` (size 3) to match `pattern` (size 50).