I have a dataframe that looks as follows:
df <- data.frame(one=c("s1_below_10", "s2_below_20"),
two=c("s3_above_10","s4_above_10"))
I want to replace all the strings by the number preceding the first underscore. In other words, the desired output is
1 3
2 4
I would like to know how I can perform this replacement (the dataset is very large). Thanks for your help.