word-cloud

Removing Words from word cloud in R

别等时光非礼了梦想. 提交于 2020-01-24 17:17:05
问题 I am able to make word cloud, but my problem is when I take the frequency of word counts, I get words whose frequency is 1. I want words whose frequency is greater than 2. How can I do that? tdm is just a term matrix. I tried with something like rowSums(m>2) , but its not working # define tdm as matrix m = as.matrix(tdm) # get word counts in decreasing order word_freqs = sort(rowSums(m), decreasing=TRUE) # create a data frame with words and their frequencies dm = data.frame(word=names(word

Shiny and twitter example

无人久伴 提交于 2020-01-15 04:19:58
问题 I'm trying to run a example to process tweets in R with Shiny. I'm using the example in this page, but I'm not getting any output. The code that I'm using is as follows (which I've corrected from the page as it had some errors with parenthesis, inverted comas, etc.): ui.r library(shiny) shinyUI(pageWithSidebar( # Application title headerPanel('Tweets hunter'), sidebarPanel( textInput('term', 'Enter a term', ''), numericInput('cant', 'Select a number of tweets',1,0,200), radioButtons('lang',

Shiny and twitter example

◇◆丶佛笑我妖孽 提交于 2020-01-15 04:19:12
问题 I'm trying to run a example to process tweets in R with Shiny. I'm using the example in this page, but I'm not getting any output. The code that I'm using is as follows (which I've corrected from the page as it had some errors with parenthesis, inverted comas, etc.): ui.r library(shiny) shinyUI(pageWithSidebar( # Application title headerPanel('Tweets hunter'), sidebarPanel( textInput('term', 'Enter a term', ''), numericInput('cant', 'Select a number of tweets',1,0,200), radioButtons('lang',

R - WordCloud2 does not always render the most frequent words

徘徊边缘 提交于 2020-01-13 10:11:36
问题 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)

TypeError: expected string or bytes-like object ( Python 3) ( Wordcloud)

北城以北 提交于 2020-01-06 05:44:08
问题 import pandas as pd import matplotlib.pyplot as plt from PIL import Image import numpy as np import wordcloud from wordcloud import WordCloud,STOPWORDS # Read the whole text. remarks = open(r'C:\Users\marmar\Remarks.txt').read().split() #Create words over an image mask = np.array(Image.open(r'C:\users\marmar\Documents\cloud.png')) #set the stopwords list stopwords= set(STOPWORDS) #append new words to the stopwords list new_words =open(r'C:\Users\marmar\Documents\comments.txt').read().split()

Why the wordcloud in the canvas is blurry?

吃可爱长大的小学妹 提交于 2020-01-03 05:37:09
问题 Here is my code in question: $(document).ready(render) function render() { wl = [['hello', 12], ['dear', 10], ['a', 9], ['Joe', 5], ['8', 2]]; $canvas = $('.wordcloud-canvas'); options = { list : wl, fontFamily : 'Times, serif', weightFactor : 2, color : '#f02222', rotateRatio : 0, rotationSteps : 0, shuffle : false, backgroundColor: 'white', drawOutOfBound : false, gridSize : 32 }; window.WordCloud($canvas[0], options); } .wordcloud-view { display: block; margin: 01px 0; width: 100%; height:

colored categories in r wordclouds

末鹿安然 提交于 2020-01-02 12:02:16
问题 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

colored categories in r wordclouds

青春壹個敷衍的年華 提交于 2020-01-02 11:59:26
问题 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

Array of tuples necessary for generate_from_frequencies method in Python wordcloud

独自空忆成欢 提交于 2019-12-24 08:47:39
问题 I am trying to make a word cloud in Python from the significance of strings and their corresponding data values in an Excel document. The generate_from_frequencies method takes a frequencies parameter which the docs say is supposed to take an array of tuples. Partial code from wordcloud source code: def generate_from_frequencies(self, frequencies): """Create a word_cloud from words and frequencies. Parameters ---------- frequencies : array of tuples A tuple contains the word and its frequency

How to remove words from wordcloud R package so that they can be included in the output?

放肆的年华 提交于 2019-12-24 02:16:43
问题 I'm using package "wordcloud" with description "Word Cloud" from the R Packages repository. When I create wordcloud from some random text, some words are omitted automatically as they should not be a part of wordcloud. Code: library(RColorBrewer) library(NLP) library(wordcloud) library(tm) wordcloud("foo bar oh oh by by bye bingo hell no", scale=c(3,1), colors=brewer.pal(6,"Dark2"),random.order=FALSE) Output: I want to keep words like "oh" and "by" in the wordcloud. How? Edit: I prefer doing