问题
How can I a draw a linechart with rcharts using nvd3 and a categorical xaxis? What I'm trying to do would look with ggplot2 like this:
library(ggplot2)
dat <- data.frame(expand.grid(group = letters[1:3], x = letters[4:6]), y = rnorm(9))
ggplot(dat, aes(x = x, y = y, group = group, color = group)) + geom_line()
I tried:
library(rCharts)
nPlot(y ~ x, group = 'group', data = dat, type = 'lineChart')
I know that I could change x to a numeric variable, but then the xaxis labels would not be correctly written.
回答1:
is this what you are after?
foo <- hPlot(x = "x", y = "y", groups = "group", data = dat, type = "line")
foo
来源:https://stackoverflow.com/questions/25481853/rcharts-nvd3-linechart-with-categorical-x-axis