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) or some other problem? How difficult is this (I know this is dependent on my abilities but would like some ball park answer)? Please advise if using base graphics may be the more sensible approach to this problem. I foresee this may be approached using panes from the plotrix package to give it the aesthetic feel that ggplot's faceting gives.

Maybe this is a foolish concept considering the size of word clouds and the way faceting quickly limits the available space.


回答1:


This may be a pipe dream, and it certainly isn't easy to re-use the wordcloud code:

  1. As Ian Fellows points out in a comment, the wordcloud code calculates word sizes and positions in base graphics.
  2. A geom-aware modification of the code needs to be aware of facets.

In terms of making it work, a framework for designing a solution might be:

  1. Rewrite wordcloud to calculate word sizes in grid graphics, rather than base graphics
  2. Write the results of word size and position to a data frame
  3. Wrap the calculations in a function called stat_wordcloud
  4. Modify geom_text to a new geom_wordcloud

So, it's a pipe dream, but I'd be keen to use it once you've made it ;-)




回答2:


This is a possible solution using ggplot2 style: https://github.com/lepennec/ggwordcloud



来源:https://stackoverflow.com/questions/11253765/geom-wordcloud-is-this-a-pipe-dream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!