Creating a plot by adding one column at a time works just fine
exPlot <- plot_ly(data.table(matrix(1:9,ncol = 3)))
theCols <- c(\"V2\",\"V3\")
exPlot &
The reason beats me but you are asking for 'any way to get around this'.
Instead of passing the whole data.table
at once, you could specify the required y-values in the loop and it should work.
df <- data.table(matrix(1:9,ncol = 3))
exPlot <- plot_ly(df[[1]])
theCols <- c("V2","V3")
for(i in 1:2){
exPlot <- add_lines(exPlot,
y = df[[theCols[i]]],
type = "scatter",
mode = "lines")
}
exPlot