Extract “words” from a string

前端 未结 4 1329
挽巷
挽巷 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:34

    You could use word() from the stringrpackage:

    > x <- c("Resistance_Test DevID (Ohms) 428", "Diode_Test SUBLo (V) 353")
    > library(stringr)
    > word(string = x, start = 4, end = 4)
    [1] "428" "353"
    

    Specifying the position of both the start and end words to be the same, you will always get the fourth word.

    I hope this helps.

提交回复
热议问题