Replacing all semicolons with a space pt2

前端 未结 2 892
生来不讨喜
生来不讨喜 2021-01-25 22:28

Im trying to run text analysis on a list of 2000+ rows of keywords, but they are listed like

\"Strategy;Management Styles;Organizations\"

So when I use tm to re

2条回答
  •  伪装坚强ぢ
    2021-01-25 23:04

    You need to split the data into a vector of strings, one of the ways to do this is by using stringr package as follows;

    library(tm)
    library(stringr)
    
    vector <- c("Strategy;Management Styles;Organizations")
    keywords <- unlist(stringr::str_split(vector, ";"))
    
    vector <- VectorSource(keywords)
    corpus <- VCorpus(vector)
    inspect(corpus[[1]])
    
    #<>
    #  Metadata:  7
    #Content:  chars: 8
    
    #Strategy
    

提交回复
热议问题