質問

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.

役に立ちましたか?

解決

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 ;-)

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top