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:
- As Ian Fellows points out in a comment, the
wordcloud
code calculates word sizes and positions in base graphics. - 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:
- Rewrite
wordcloud
to calculate word sizes in grid graphics, rather than base graphics - Write the results of word size and position to a data frame
- Wrap the calculations in a function called
stat_wordcloud
- Modify
geom_text
to a newgeom_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
来源:https://stackoverflow.com/questions/11253765/geom-wordcloud-is-this-a-pipe-dream