ggvis 中的堆积图,用于连续数据的 rcharts

Stacked chart in ggvis, rcharts for continuous data

下面是我拥有的数据的一个子集。

Abby    John       Mike             Date
4.0       6         3               03-30
3.2       5         1               03-31
4.0       6         3               04-01
4.1       8         2               04-02
6.0       6         1               04-03

我正在尝试绘制一个 stacked/grouped 条形图,在 x 轴上显示日期,在 Y 轴上显示所有用户数据(对于特定日期,Y 轴上的 3 个分组条形图表示 Abby、John 和 Mike 的数据).我尝试使用 Rcharts 库示例位于:http://ramnathv.github.io/posts/rcharts-nvd3/index.html

但与那里使用的不同,我的数据是连续的,不是一个因素。无论如何我可以使用 ggvis 或 rCharts 来做到这一点吗?我目前只用过这两个绘图库。

感谢任何帮助或指导。谢谢

你可以在RCharts中使用Highcharts来做你想做的事。请注意,您可能需要对数据进行一些操作...

rm(list = ls())
library(rCharts)

# Prepare data
x <- data.frame(USPersonalExpenditure)
colnames(x) <- substr(colnames(x), 2, 5)
Names <- rownames(x)
Dates <- colnames(x)
colnames(x) <- Names
rownames(x) <- Dates

# Create chart
a <- rCharts:::Highcharts$new()
a$chart(type = "column")
a$title(text = "US Personal Expenditure")
a$xAxis(categories = rownames(x))
a$plotOptions(column = list(stacking = "normal"))
a$yAxis(title = list(text = "Billions of dollars"))
a$data(x)
a