【发布时间】:2016-01-27 15:17:20
【问题描述】:
抱歉,现在我明白我的问题有点含糊。我正在现场环境中工作,请在下面找到一些盲测数据:-
structure(list(Rco = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A220",
"B334"), class = "factor"), month = structure(c(2L, 1L, 3L, 2L,
1L, 3L), .Label = c("Feb", "Jan", "Mar"), class = "factor"),
Count = c(12, 22, 33, 44, 55, 66)), .Names = c("Rco", "month",
"Count"), row.names = c(NA, 6L), class = "data.frame")
然后我将在此数据上生成一个条形图(使用 Rcharts),如下所示:-
b <- hPlot(x = 'Rco', y = 'Count', data = test, type = 'bar', group = 'month',title = "AAAAAA", subtitle = "Bar Graph")
现在这完全符合我的目的,但是当我遇到所有月份的数据都不存在的情况时(请在下面的情况下)我得到不正确的输出:-
测试
b <- hPlot(x = 'Rco', y = 'Count', data = test, type = 'bar', group = 'month',title = "AAAAAA", subtitle = "Bar Graph")
请对数据运行 Rcharts::hplot 函数,您会发现代表代码的条形混淆了(对于 C123 和 B334)。
我在互联网上找不到任何说明这是 Rcharts 中的一个问题的参考资料,所以我想我会通过为每个 Rco 制作额外的行并用零填充它们来处理它,这样我就可以拥有一个数据框每个 R co 每月 1 条记录。此外,可能有超过 4 个月的数据 - 数据可能是一年或 2 年,所以我必须使其动态化。
任何帮助将不胜感激。
提前致谢
【问题讨论】: