My dataframe is one column and goes like:
df<- data.frame(col = c(
"cat-dog-cat999-dog dog-mouse 23",
"dog2-cat45-mouse-cat 7",
"dog 4",
"dog6-dog-cat3-cat 6")
)
I want to end with a column with only the last digits in each row, so the output would have the column
(23,
7,
4,
6 )
I think there are two options: either split at the last number preceded with a space or split at the last number in each raw.
Any ideas?