I have a data frame with the following structure, titled "final_proj_data"
ID County Population Year
<dbl> <chr> <dbl> <dbl>
1003 Baldwin County, Alabama 169162 2006
1015 Calhoun County, Alabama 112903 2006
1043 Cullman County, Alabama 80187 2006
1049 DeKalb County, Alabama 68014 2006
I am trying to split the column County into two different columns, County and State, and remove the comma.
I tried a number of permutations of the separate() function but I keep getting back this error:
Error:
var
must evaluate to a single number or a column name, not a character vector
I've tried (among others)
final_proj_data %>%
separate(final_proj_data$County, c("State", "County"), sep = ",", remove = TRUE)
final_proj_data %>%
separate(data = final_proj_data, col = County,
into = c("State", "County"), sep = ",")
I'm not sure what I am doing wrong, or why the "col =" keeps throwing this error. Any help would be appreciated!