hadley / r2d3

ggplot2 + d3 = r2d3
184 stars 29 forks source link

r2d3 example crashes due to 'as.list.proto' #1

Open chiphogg opened 12 years ago

chiphogg commented 12 years ago

I'm having trouble with the r2d3 example:

p <- qplot(displ, hwy, data = mpg)
r2d3(p, "mpg.json")
r2d3(p + geom_smooth(), "mpg-smooth.json")

The trouble shows up with the second line, but I think it actually starts in the first: if you try executing print(p), you also get the crash.

In either case, the error is:

Error in as.list.proto(this, ...) : attempt to apply non-function

Curiously, this line (which seems to be ggplot2-only) works fine until r2d3 is loaded, as the following commands from R --vanilla demonstrate:

> library(ggplot2)
> qplot(displ, hwy, data = mpg)
> library(r2d3)
Loading required package: digest
> qplot(displ, hwy, data = mpg)
Error in as.list.proto(this, ...) : attempt to apply non-function
chiphogg commented 12 years ago

Also, this seems as good a place as any to say it: I was just about to start work on an R package of this name, trying to interface R to d3. Seems you beat me to the punch to grab this clever name! :)

hadley commented 12 years ago

This is obviously still pretty experimental, so no guarantees anything works, sorry! Will hopefully get back to it soon.

chiphogg commented 12 years ago

I figured as much. Can't wait to see what you come up with!

In the meantime: have you seen polychart.js? It's a javascript implementation of the Grammar of Graphics, and it's based on d3. There (obviously) seems to be some overlap with your ideas about R and d3.

mskyttner commented 12 years ago

I am very excited about this package, but not skilled enough with R to figure out what to do about this issue. I tried just commenting out the function that seems to be the culprit in the r2d3/R/ggplot2.r file, i.e.

as.list.proto <- function(x, ...) x$as.list(...)

and after doing that I seem to be able to run r2d3 without getting that error message, but I don't really know what other things I'm breaking by doing that...

Anyhow this a superexciting package to watch, in my opinion! It would be so nice to get interactive ggplot visualization for the web from R through d3. What a dream to be able to generate interactive web dashboards from R connected to live data... all open source, free and high quality!