I am a beginner in R and I didn't find what I was looking for on the Internet. While I managed to replace values like "2 years" with "2', for example, I still have a value "10+ years" in the column "emp_length" in my dataframe, which I couldn't replace with the following ways:
df2$emp_length <- gsub("10+ years", '10', df2$emp_length)
df2$emp_length = str_replace(df2$emp_length, "10+ years", "10")
Below I provide a sample of the dataframe, where I also put additional and irrelevant column "annual_inc", due to not getting a text beginning with "structure...", like it should, I think.
structure(list(emp_length = c("10+ years", "0", "10+ years",
"10+ years", "1"), annual_inc = c(24000, 30000, 12252, 49200,
80000)), row.names = c(NA, 5L), class = "data.frame")