I have a dataframe (df) with a column (Col2) like this:
Col1 Col2 Col3
1 C607989_booboobear_Nation A
2 C607989_booboobear_Nation B
3 C607989_booboobear_Nation C
4 C607989_booboobear_Nation D
5 C607989_booboobear_Nation E
6 C607989_booboobear_Nation F
I want to extract just the number in Col2
Col1 Col2 Col3
1 607989 A
2 607989 B
3 607989 C
4 607989 D
5 607989 E
6 607989 F
I have tried things like:
gsub("^.*?_","_",df$Col2)
but it's not working.