问题
I was using {tm} package and then generated a corpus using
corpus = Corpus(VectorSource(sample.words))
then I want to check the content in corpus ,but it print this instead of its texts:
> corpus
<<VCorpus>>
Metadata: corpus specific: 0, document level (indexed): 0
Content: documents: 3933
Now I have found some methods to look into corpus
,then I started wondering what exactly R print when an object was typed in ?
> class(corpus)
[1] "VCorpus" "Corpus"
> typeof(corpus)
[1] "list"
Why it didn`t like other ordinary lists ,printing its columns and rows?Does this has something to do whit the class attribute?
I`m new in R and not familiar with some basic concepts, thanks for your patience!
回答1:
The introduction document to the tm
package says that you can use , say, writeLines(as.character(mycorpus[[4]]))
to get a textual representation of document 4.
You can also use content(myCorpus[[23]])
.
To read the intro document, enter browseVignettes()
on your R prompt and the search for it on the browser window that will have opened.
来源:https://stackoverflow.com/questions/34236346/how-to-print-textual-representation-of-single-documents-stored-in-a-tm-corpus-in