I'm having trouble with creating a list of plots using for loops, and I don't know why.
Here's the code that doesn't work (i.e. returns aplotfinal
as an empty list)
aplotfinal <- list()
for(i in 1:length(Rlist)){
a <- Rlist[[i]] %>%
select(Frame_times, average)
del <- 0.016667
x.spec <- spectrum(a$average, log = "no", plot = FALSE)
spx <- x.spec$freq/del
spy <- 2*x.spec$spec
aplotfinal[[i]] <- plot(spy~spx, main = names(Rlist)[i], xlab = "frequency", ylab = "spectral density", type = "l")
}
The plot
function works, I just want to apply it for a list of dataframes that I have (i.e. Rlist
). Thank you!