2015-04-29 29 views
0

我正在使用tm和tm.plugin.webmining包來嘗試閱讀一些Goggle新聞並對它們進行一些基本分析。然而,我在一開始就面臨着一個問題:R錯誤GoogleNewsSource繼承(x,「Source」)不是TRUE

googleNewsCorpus <- Corpus (GoogleNewsSource("Google")) 

我得到以下錯誤:

Error: inherits(x, "Source") is not TRUE 

請幫助。我正在使用R版本3.1,R Studio版本0.98.1091,tm版本0.6和tm.plugin.webmining版本1.2.2。

回答

0

解決!我把結果變成WebCorpus:

gnewsCorpus <- WebCorpus(GoogleNewsSource("Google")) 

我現在可以用這個後續的「以舊換新」分析:

data <- tm_map(gnewsCorpus,removeWords, stopwords("english")) 
... 

一個相關的問題,雖然:我已經做了所有的分析後,創建了一個term-document matrix,使用hclust()進行聚類,如何將新聞標題放入聚類樹狀圖?

... 
tdm <- TermDocumentMatrix(data) 
h <- hclust(dist(t(tdm),method="cosine")) 
plot(h) 
0

相關查詢也是這樣回答:

newsheadings <- character(length(gnewsCorpus)) 
for (i in 1:length(gnewsCorpus)){ 
    newsheadings[i] <- gnewsCorpus[[i]]$meta$heading 
} 
... 
plot(h, labels = newsheadings)