d3scatter
d3scatter copied to clipboard
d3scatter errors if data is a matrix
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.