2

Using library(rCharts), and the exact same plotting code, why do some of these data.frames get plotted, and some don't?

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

Session Info

enter image description here

tospig
  • 7,762
  • 14
  • 40
  • 79
  • @jenesaisquoi - yes, Rstudio here too. I've added a screenshot showing my `sessionInfo`, and a plot – tospig Feb 11 '16 at 08:43

0 Answers0