word-cloud

colored categories in r wordclouds

烂漫一生 提交于 2019-12-06 11:27:36
Using the wordcloud package in R I would like to color different words according to a categorical variable in the dataset. Say my data is as follows: name weight group 1 Aba 10 x 2 Bcd 20 y 3 Cde 30 z 4 Def 5 x And here as a dput : dat <- structure(list(name = c("Aba", "Bcd", "Cde", "Def"), weight = c(10, 20, 30, 5), group= c("x", "y", "z", "x")), .Names = c("name", "weight", "group"), row.names = c(NA, -4L), class = "data.frame") Is there a way in wordcloud() to color the names by their group (x, y, z) or should I use different software/packages? It will automatically choose from a color list

Making a wordcloud, but with combined words?

我与影子孤独终老i 提交于 2019-12-06 10:16:44
问题 I am trying to make a word cloud of publications keywords. for example: Educational data mining; collaborative learning; computer science...etc My current code is as the following: KeywordsCorpus <- Corpus(VectorSource(subset(Words$Author.Keywords, Words$Year==2012))) KeywordsCorpus <- tm_map(KeywordsCorpus, removePunctuation) KeywordsCorpus <- tm_map(KeywordsCorpus, removeNumbers) # added tolower KeywordsCorpus <- tm_map(KeywordsCorpus, tolower) KeywordsCorpus <- tm_map(KeywordsCorpus,

d3.js word missing from word cloud

筅森魡賤 提交于 2019-12-06 09:08:48
js and trying to do word cloud base on the sample code from [here]: https://github.com/jasondavies/d3-cloud . What i trying to do is the font size of the words is base on the frequency of the words in array. For example i have [a,a,a,b,b] so the word 'a' will be larger than 'b' but the problem is when the width or height of the word is larger than the < svg > the word will be gone. layout = d3.layout.cloud().size([w, h]) .words(frequency_list) .padding(5) .rotate(function() { return ~~(Math.random() * 2) * 90; }) .font(d3.select("#font").property("value")) .fontSize(function(d) { return (d

IOError: cannot open resource

怎甘沉沦 提交于 2019-12-06 07:18:12
I have a code on ipython notebook where I am attempting to make a wordcloud, but I get an error. From what I could see, the error is related to something else and not my code (something with fonts?) --------------------------------------------------------------------------- IOError Traceback (most recent call last) <ipython-input-71-795b92e06f22> in <module>() 4 # print x[0], x[1] 5 ----> 6 genWordCloud(list_of_tuples) <ipython-input-70-55c34fb2c915> in genWordCloud(filename) 15 count = filename 16 #words = myWC.fit_words(count, width=500, height=500) ---> 17 words = myWC.fit_words(count) 18

WordCloud from data frame with frequency python

痴心易碎 提交于 2019-12-06 05:48:28
问题 i have a dataframe as bellow Int64Index: 14830 entries, 25791 to 10668 Data columns (total 2 columns): word 14830 non-null object coef 14830 non-null float64 dtypes: float64(1), object(1) i try to make word cloud with coef as a frequency instead count for ample text = df['word'] WordCloud.generate_from_text(text) TypeError: generate_from_text() missing 1 required positional argument: 'text' or text = np.array(df['word']) WordCloud.generate_from_text(text) TypeError: generate_from_text()

d3.js Tag Cloud size from a Json/array?

只谈情不闲聊 提交于 2019-12-06 02:45:03
问题 I am modifying this code: https://github.com/jasondavies/d3-cloud <script> d3.layout.cloud().size([300, 300]) .words([ "Hello", "world", "normally", "you", "want", "more", "words", "than", "this"].map(function(d) { return {text: d, size: 10 + Math.random() * 90}; })) .rotate(function() { return ~~(Math.random() * 2) * 90; }) .fontSize(function(d) { return d.size; }) .on("end", draw) .start(); function draw(words) { d3.select("body").append("svg") .attr("width", 300) .attr("height", 300)

Creating a subset of words from a corpus in R

自闭症网瘾萝莉.ら 提交于 2019-12-05 16:43:18
I have a 1,500-row vector created from a Twitter search using the XML package. I have then converted it to a Corpus to be used with the tm package. I want to ultimately create a wordcloud with some (the most frequent) of those words, so I converted it to a TermDocumentMatrix to be able to find terms with a minimum frequency. I create the object "a", which is a list of those terms. a <- findFreqTerms(mydata.dtm, 10) The wordcloud package does not work on document matrices. So now, I want to filter the original vector to include only the words included in the "a" object (If I use the object

geom_wordcloud : is this a pipe dream

倾然丶 夕夏残阳落幕 提交于 2019-12-05 13:07:53
问题 I deal a bit with textual data across various grouping variables. I'm thinking of creating a method to make faceted wordcloud plots using Ian Fellows' wordcloud package. I like the way ggplot2 facets social variables. I'm deciding how to approach this problem (faceted wordcloud plot). Is it possible to use Fellows' work as a geom (I've never made a geom but may learn if this is doable) or will ggplot not play nicely because one is grid and one is base (and wordcloud also uses some C coding)

Spaces in wordcloud

↘锁芯ラ 提交于 2019-12-05 11:53:08
I currently use wordle for many artsy uses of the word cloud. I think that R's word cloud, potentially, has better control. 1) How do you keep a word capitalized in the word cloud? [SOLVED] 2) How do keep two words as one chunk in the wordcloud? (wordle uses the ~ operator to accomplish this, R's word cloud merely prints the ~ as is) [For instance where there's a ~ between "to" and "be" I'd like a space in the word cloud] require(wordcloud) y<-c("the", "the", "the", "tree", "tree", "tree", "tree", "tree", "tree", "tree", "tree", "tree", "tree", "Wants", "Wants", "Wants", "Wants", "Wants",

R - WordCloud2 does not always render the most frequent words

痴心易碎 提交于 2019-12-05 09:59:27
I use the wordcloud2 package to render word clouds. It seems that wordcloud2 does not always display the most frequent words. I said "not always" because the problem is not permanent. It seems that the results are mostly random. Code : library(wordcloud2) library(htmlwidgets) DataCloud <- as.character(DataTextAnalysis[,1]) DataCloud <- as.data.frame(table(DataCloud)) DataCloud <- DataCloud[order(DataCloud$Freq, decreasing = TRUE),] DataCloud <- DataCloud[1:10, ] wordcloud2(data = DataCloud) Data : structure(list(`Theme 1` = structure(c(12L, NA, 2L, 4L, 6L, 7L, NA, 14L, 6L, 6L, 2L, 7L, 5L, 2L,