d3scatter icon indicating copy to clipboard operation
d3scatter copied to clipboard

d3scatter errors if data is a matrix

Open dmurdoch opened this issue 6 years ago • 0 comments

If my data is in a matrix, d3scatter can't plot it:

library(d3scatter)
xy <- matrix(rnorm(20), ncol = 2, dimnames = list(NULL, c("x", "y")))
d3scatter(xy, ~x, ~y)

# Error in eval(value[[2]], data, environment(value)) : 
# numeric 'envir' arg not of length one

I get the same error if I put xy in a shared data object, i.e.

library(crosstalk)
sxy <- SharedData$new(xy)
d3scatter(sxy, ~x, ~y)

A fix is data <- as.data.frame(data) early in d3scatter(), but this should probably be done conditionally, and I'm not sure what the condition should be.

dmurdoch avatar Dec 22 '17 19:12 dmurdoch