I have a dataframe that looks like this. I named this "df_raw".
"HRHHID\t15\tHOUSEHOLD IDENTIFIER\t(Part 1)\t1- 15"
"HRMONTH\t2\tMONTH OF INTERVIEW\t16-17"
"HRYEAR4\t4\tYEAR OF INTERVIEW\t\t18-21"
"HURESPLI\t2\tLINE NUMBER OF THE RESPONDENT\tCURRENT\t22 - 23" "FILLER\t2\t\t27 - 28" ...
I am trying to extract the number range at the end, such as 1- 15, 16-17, 18-21 and so on.. I prepared my regex syntax on a regex tester (https://regexr.com/63nl1) and it seems to target what I want.
Regex: \d+(\s?)-(\s?)\d+$
Then I go to R and try to use the extract function in tidyr (this is the first time using it for me) and I get the error: "Error: regex should define 1 groups; found."
df_raw %>%
extract(col = value, into = "", regex = "\\d+(\\s?)-(\\s?)\\d+$")
Can anyone help me understand how to group my regex so that the extract function works?
Thanks very much, David