How to show corpus text in R tm package?

前端 未结 8 816
一个人的身影
一个人的身影 2020-12-14 23:49

I\'m completely new in R and tm package, so please excuse my stupid question ;-) How can I show the text of a plain text corpus in R tm package?

I\'ve loaded a corpu

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 00:03

    You can try converting your corpus text into a dataframe, and accessing the required text from the dataframe itself. I have used the built-in sample data "crude" (from the tm package) as an example.

    data("crude")
    dataframe<-data.frame(text=unlist(sapply(crude, `[`, "content")), stringsAsFactors=F)
    
    dataframe[1,]
    [1] "Diamond Shamrock Corp said that\neffective today it had cut its contract prices for crude oil by\n1.50 dlrs a barrel.\n    The reduction brings its posted price for West Texas\nIntermediate to 16.00 dlrs a barrel, the copany said.\n    \"The price reduction today was made in the light of falling\noil product prices and a weak crude oil market,\" a company\nspokeswoman said.\n    Diamond is the latest in a line of U.S. oil companies that\nhave cut its contract, or posted, prices over the last two days\nciting weak oil markets.\n Reuter"
    

提交回复
热议问题