-
Notifications
You must be signed in to change notification settings - Fork 636
Closed
Description
Hi,
I'm just wondering why the following plots turn out differently (I only change 3 numbers to a variable containing them (i). Even when I run the code lines one after another.
Interestingly, if I use different variable names (i,j,k, etc), I get the expected result.
library(plotly)
#### Code 1
df <- data.frame(a1=seq(1,20), a2=seq(21,40), a3=seq(41,60))
p <- df %>% plot_ly(x = ~seq(1,dim(df)[1]))
i=1
p <- p %>% add_trace(y = ~ df[,paste0('a',1)])
i=2
p <- p %>% add_trace(y = ~ df[,paste0('a',2)])
i=3
p <- p %>% add_trace(y = ~ df[,paste0('a',3)])
p
#### Code 2
df <- data.frame(a1=seq(1,20), a2=seq(21,40), a3=seq(41,60))
p <- df %>% plot_ly(x = ~seq(1,dim(df)[1]))
i=1
p <- p %>% add_trace(y = ~ df[,paste0('a',i)])
i=2
p <- p %>% add_trace(y = ~ df[,paste0('a',i)])
i=3
p <- p %>% add_trace(y = ~ df[,paste0('a',i)])
pMetadata
Metadata
Assignees
Labels
No labels