I have a data.frame df with a character column text that contains text. From that column, I would like to extract all percentage numbers (say, 1.2% and -2.3%) but not the ordinary numbers (say, 123 and 1.2) into a character vector.
A small example:
df <- data.frame(text = c("this text is 1.3% this is +1.4% and this -1.5%", "this text is 123.3% this 123.3 and this 1234.5")) Required output:
[1] "1.3%" "-1.4%" "-1.5%" "123.3%" Is that possible?