繁体   English   中英

从R脚本创建Waffle图表时出现问题

[英]Problems creating a Waffle chart from an R script

我正在R( https://github.com/hrbrmstr/waffle )中测试Waffle软件包,我正在Microsoft Windows 10下使用R版本3.2.2(32位),当我要绘制R脚本的华夫饼图。

如果直接从R控制台绘制Waffle图表,则在绘制此图表时不会出现问题,仅当从R脚本加载图表时才会出现此问题,并且不会显示该问题。

这是我的R脚本中的代码:

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

简单的解决方案是在脚本中显式打印图

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

然后调用脚本

source("test.R")

和voilà:

华夫饼图

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM