alternatively, a straight solution would be of this type:
example_str <- c("not a value",rep("0 - exdis",3),rep("10 - ex sat",4),rep("1",5),rep("6",2))
table(example_str)
my_str_recoded <- gsub(x =example_str ,
pattern = "0 - exdis",
replacement = "0")
my_str_recoded <- gsub(x =my_str_recoded ,
pattern = "10 - ex sat",
replacement = "10")
table(my_str_recoded)
my_vals<-readr::parse_integer(my_str_recoded)
table(my_vals,useNA ="ifany")
my_vals_no_na <- my_vals[which(!is.na(my_vals))]
table(my_vals_no_na,useNA ="ifany")