使用library(rCharts)
和完全相同的绘图代码,为什么会绘制其中一些data.frame
,有些则不会?
## Install:
# library(devtools); install_github('ramnathv/rCharts'); library(rCharts)
## Successful plot
set.seed(1)
df <- data.frame(var1 = letters,
var2 = rnorm(26, 0, 1))
rPlot(x = list(var = "var1", sort = "var2"), y = "var2", data = df, color = "var1", type = "bar")
## No Plot
set.seed(1)
df <- data.frame(var1 = 1:26,
var2 = rnorm(26, 0, 1))
rPlot(x = list(var = "var1", sort = "var2"), y = "var2", data = df, color = "var1", type = "bar")
## No Plot
set.seed(1)
df <- data.frame(var1 = 1:26,
var2 = rnorm(26, 0, 1))
## convert to char
df$var1 <- as.character(df$var1)
rPlot(x = list(var = "var1", sort = "var2"), y = "var2", data = df, color = "var1", type = "bar")
## Successful plot
set.seed(1)
df <- data.frame(var1 = 1:26,
var2 = rnorm(26, 0, 1))
## paste a string onto var1
df$var1 <- paste0(df$var1, "_")
rPlot(x = list(var = "var1", sort = "var2"), y = "var2", data = df, color = "var1", type = "bar")
会话信息