r - Producing multiple qplots with data.table -
i'd produce 1 scatter plot per group data.table , return function.
i can produce different charts using plot (below) assume isn't data.table issue:
dt = data.table(a = c(1,2,3,4), b = c(1,1,2,2), c = c(4,5,6,7)) result = dt[, list(plot = list(plot(a, c))), = b]
however if try same qplot (in order plots can return), appear end 2 copies of second chart.
dt = data.table(a = c(1,2,3,4), b = c(1,1,2,2), c = c(4,5,6,7)) result = dt[, list(plot = list(qplot(a, c))), = b] result[1,][["plot"]] result[2,][["plot"]]
apologies if i'm missing obvious / doing stupid.
i'm not 100% sure what's going on, here workaround:
result = dt[, list(plot = list(qplot(data=.sd, a, c))), = b]
it seems data.table
reserves environment execute evaluations in in way, , qplot
stores reference environment. since don't specify data
argument, qplot
in environment data, keeps getting changed each by
value data.table
, after data.table
operation, last piece left there.
Comments
Post a Comment