The same graph plotted [ggplot2]

34 views Asked by At

I came across a problem with creating a list of plots. I have created garch predictions and I have those values in list:

for(i in 1:length(Tickery))
{
name <- paste(Tickery[i])
log_ret <- diff(log(CP_list[[i]]))
log_ret_list[[name]] <- log_ret
gspec.ru <- ugarchspec(mean.model=list(
armaOrder=c(0,0)),
distribution="std")
gfit.ru <- ugarchfit(gspec.ru, log_ret)
GARCH_list[[name]] <- gfit.ru@fit$sigma
}

So values for different stocks are in GARCH_list[[i]]. I have tried to make a list of plots of those volatilities:

for(i in 1:length(Tickery))
{
a <- ggplot(NULL, aes(x = 1:length(GARCH_list[[i]]), y = GARCH_list[[i]])) + 
     geom_line() + 
     labs(x = "Obserwacje", y = "Zmienność", title = paste(Tickery[i]))
pl[[i]] <- a
}

Unfortunately in every item of list (pl[[i]]) I have the same plot, the last one. What's wrong in my code?

0

There are 0 answers