Ответ 1
Вы хотите сделать что-то вроде этого?
n=1000
df=data.frame(time=1:n,y=runif(n))
window=100
for(i in 1:(n-window)) {
flush.console()
plot(df$time,df$y,type='l',xlim=c(i,i+window))
Sys.sleep(.09)
}
Просматривая свой код:
# for(i in 1: length(temp$Time[1:10000])) {
for (i in 1:10000) # The length of a vector of 10000 is always 10000
flush.console()
# plot(temp$Time[i:i+100],temp$Open[i:i+100],
# Don't bother subsetting the x and y variables of your plot.
# plot() will automatically just plot those in the window.
plot(temp$Time,temp$Open,
xlim=c(as.numeric(temp$Time[i]),as.numeric(temp$Time[i+150]))
# Why are you setting the y limits dynamically? Shouldn't they be constant?
# ,ylim=c(min(temp$Open[i:i+100]),max(tmep$Open[i:i+120])))
Sys.sleep(.09)
}