Home > OS >  str_extract// from a specific row that starts with: "More" =string name ,I have a set of n
str_extract// from a specific row that starts with: "More" =string name ,I have a set of n

Time:01-14

1

I am trying to extract from a data set like this one above the numbers from the row named waiting into a new column but if I try to do the result is correct in some rows but others are giving me the last numbers on other rows .

I would like to have the information from the specific row including decimals, into a new column but not to get the other numbers .

CodePudding user response:

Please try this

library(stringr)
data <- c('t1 waiting 1234', 'waiting 1234.5')
data <- trimws(str_extract_all(data, '\\s\\d.*'))
data
  • Related