How to get the first 10 words in a string in R?

后端 未结 4 1187
清歌不尽
清歌不尽 2020-12-17 00:00

I have a string in R as

x <- \"The length of the word is going to be of nice use to me\"

I want the first 10 words of the above specifi

4条回答
  •  有刺的猬
    2020-12-17 00:18

    How about using the word function from Hadley Wickham's stringr package?

    word(string = x, start = 1, end = 10, sep = fixed(" "))

提交回复
热议问题