1

I am testing the Waffle package in R (https://github.com/hrbrmstr/waffle), I am using R version 3.2.2 (32 bits) under Microsoft Windows 10, and I am having problems when I want to plot a Waffle chart from an R script.

If I plot a Waffle chart directly from the R console, I have no problems plotting this chart, this issue only arises when I load the chart from a R script and it is not displayed.

This is the code on my R script:

library(waffle)
mm.counts <- c(12, 6, 8, 10, 6, 7)
names(mm.counts) <- c("blue", "brown", "green", "orange", "red", "yellow")
waffle(mm.counts, rows = 7, colors = names(mm.counts), title = "M&M Colors")
Marcus Campbell
  • 2,746
  • 4
  • 22
  • 36
  • Thanks for trying the pkg out! Can you post a minimal reproducible R script (all `library` calls) and also how you're calling it (i.e. `Rscript`, `littler`, `R` with options, etc). Feel free to toss this additional info into an [issue](https://github.com/hrbrmstr/waffle/issues) as well (you can ref the SO thread). – hrbrmstr Sep 28 '15 at 12:46
  • deat @hrbrmstr thanks for your fast response, the code I posted on my question is the same I have in my script, I have no other calls. – Arturo Mora-Soto Sep 29 '15 at 13:38
  • oh, i misunderstood (I though you were running this from a batch script). you should at least have a `library(waffle)` in your R script then. – hrbrmstr Sep 29 '15 at 13:42

1 Answers1

0

The easy solution is to explicity print the plot in the script

> test.R

library(waffle)
mm.counts <- c(12, 6, 8, 10, 6, 7)
names(mm.counts) <- c("blue", "brown", "green", "orange", "red", "yellow")
wp <- waffle(mm.counts, rows = 7, colors = names(mm.counts), title = "M&M Colors")
print(wp)

then call the script

source("test.R")

and voilà:

waffle plot

Roman
  • 4,744
  • 2
  • 16
  • 58