I'm trying to add_trace ad each loop, but I get only one plot with multiplies lines on over each other.
mean <- -0.0007200342
sd <- 0.3403711
N=10
T=1
Delta = T/N
W = c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd)))
t <- seq(0,T, length=N+1)
p<-plot_ly(y=W, x=t)
for(i in 1:5){
W <- c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd)))
p<-add_trace(p, y=W)
}
print(p)
y=W
,W
is first found within the environment of the plot. Directly usingp<-add_trace(p, y=c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd))))
resolves the issue, but I imagine you are looking for a more general solution. – Axeman