I am looking to divide this into two variables. Ideally, I would have one variable with just the items, and another with just the numbers. Of course, deleting the intermittent periods is the biggest challenge I face. Anyone have any tips? Thanks in advance.
Asked
Active
Viewed 124 times
-2
-
3Could you please share your data using dput(
) instead of posting a picture? – Mario Niepel Jan 07 '21 at 19:20 -
Related, possible duplicate of https://stackoverflow.com/q/14383710/680068 – zx8754 Jan 07 '21 at 19:25
-
1Yes, it has been converted. Apologies, this is my first post. – Abc Jan 07 '21 at 19:54
1 Answers
1
look at stringr
package and the str_match
function. Something like
library(stringr)
str_match(df$V1,"([\\w ]+)[,]+([0-9.]+)")
You will need to learn some regex. I cannot test my answer, as you don't provide data in your post. Please paste the output of dput(your_df)
in your post

denis
- 5,580
- 1
- 13
- 40