Extract “words” from a string

前端 未结 4 1331
挽巷
挽巷 2021-01-14 07:47

I have a table with 153 rows by 9 columns. My interest is the character string in the first column, I want to extract the fourth word and create a new list from this fourth

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-14 08:13

    If you are not familiar with regular expressions, the function strsplit can help you :

    data <- c('Resistance_Test DevID (Ohms) 428', 'Diode_Test SUBLo (V) 353')
    unlist(lapply(strsplit(data, ' '), function(x) x[4]))
    [1] "428" "353"
    

提交回复
热议问题