I have a column like this but I need to separate the weight digits from the chips name. Using grepl() function.
productWords[grepl(pattern = "![:digit:]", x= productWords)]
it's not working :/
I have a column like this but I need to separate the weight digits from the chips name. Using grepl() function.
productWords[grepl(pattern = "![:digit:]", x= productWords)]
it's not working :/
Try this with stringr
package
x <- "Natural Chip 175g"
stringr::str_extract(x, '[0-9]{3}g')
If weights can have more than 3 digits, try this -
stringr::str_extract(x, '[0-9]+g')