Splitting text column into ragged multiple new columns in a data table in R

后端 未结 5 1684
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 07:58

I have a data table containing 20000+ rows and one column. The string in each column has different number of words. I want to split the words and put each of them in a new c

5条回答
  •  情话喂你
    2020-12-06 08:44

    An example data would be nice, but if I understand what you want, it is not possible to do properly in a data frame. Given there are different numbers of words in each row you, will need a list. Even though, it is very simple to split the words in the whole object.

    If you run strsplit(as.character(Data[,1]), " ") you will get a list with each element corresponding to a row in your dataframe. From that, there are several different alternatives to rearrange this object, but the best approach will depend on your objective

提交回复
热议问题