私はこの問題の解決策を何時間も探しました - 多くの情報を入力しましたが、まだ正しい解決策はありません. 誰かが私を助けてくれることを願っています。
私の目的: 私のワードクラウドは、定義された多角形 (x 座標と y 座標) に収まります。
私が持っているのは、2つの主なアプローチです。
- アプローチ:Rパッケージで試す
wordcloud
私は持っている:
a) 完成したwordcloud
wordcloud(my_wordcloud, scale=c(4,0.5), max.words=500, min.freq="2", random.order=FALSE, rot.per=0.05, use.r.layout=FALSE,colors=brewer.pal(6,"Dark2"))
b) 定義された多角形
plot(my_coordinates, type="l", axes = F, xlab = NA, ylab = NA)
今、私はプロットで両方をまとめましたpar(new=TRUE). これまでの結果は次のとおりです。

ご覧のとおり、単語はポリゴンで一致していません。私の問題は、wordcloud;の周辺地域の兆候がないことです。ポリゴンの座標を渡す場所がわかりません。
私の最初のアプローチのコード:
#librarys
library("SnowballC", lib.loc="~/R/i686-pc-linux-gnu-library/3.1")
library("tm", lib.loc="~/R/i686-pc-linux-gnu-library/3.1")
library("wordcloud", lib.loc="~/R/i686-pc-linux-gnu-library/3.1")
#Corpus (txt-file)
corp <- Corpus (DirSource("in/test"))
corp <- tm_map(corp, stripWhitespace)
corp <- tm_map(corp, tolower)
corp <- tm_map(corp, removeWords, stopwords("german"))
corp <- tm_map(corp, stripWhitespace)
corp <- tm_map(corp, removePunctuation)
#make a txt-file
corp_clean <- tm_map(corp, PlainTextDocument)
#the coords as csv (columns: x, y)
ch <- read.csv(file="coord/cord_ch.csv", sep = ";")
# Wordcloud
wordcloud(corp_clean, scale=c(4,0.5), max.words=100, min.freq="3", random.order=FALSE, rot.per=0.05, use.r.layout=FALSE,colors=brewer.pal(6,"Dark2"))
# new Plot
par(new=TRUE)
#plot the coords
plot(ch, type="l", axes = F, xlab = NA, ylab = NA, ylim = rev(range(ch$y)))
今私の2番目のアプローチ:
2 アプローチ: テキスト
this の助けを借りて、次のコードにたどり着きました:
#after some steps from my first approach (we begin with #make a txt-file from above code)
corp_clean <- tm_map(corp, PlainTextDocument)
# some definings
myTdm <- TermDocumentMatrix(corp_clean)
termFrequency <- rowSums(as.matrix(myTdm))
termFrequency <- subset(termFrequency, termFrequency>=3)
df <- data.frame(term=names(termFrequency), freq=termFrequency)
m <- as.matrix(myTdm)
wordFreq <- sort(rowSums(m), decreasing=TRUE)
#plot the coordinates
plot(ch, type="l", axes = F, xlab = NA, ylab = NA, ylim = rev(range(ch$y)))
par(new=TRUE)
#plot the text (wordcloud) by telling the coordinates
text(x = ch$x, y = ch$y,labels = names(wordFreq))
そのコードを使用すると、結果のプロットは次のようになります。

ここでは、座標の位置に単語があります。座標をテキストの周囲領域として宣言することは可能ですか?
私のアプローチの 1 つが R 専門家の 1 人から修正されることを願っています。
よろしくお願いします。さらに何か必要な場合は、お知らせください。