0
逐次インクリメントされていない
library(quantmod)
#input symbol, start and end dates:
my_symbol<-readline("What symbol would you like analyzed?")
start_date <- readline("When do you want the series to start?")
end_date <- readline("When do you want the series to end?")
start_date2 <- readline("When do you want the scaled series to start?")
end_date2 <- readline("When do you want the scaled series to end?")
data1 <- as.data.frame(getSymbols(my_symbol, from = start_date, to = end_date, env = NULL))
data2<- getSymbols(my_symbol, from = start_date2, to = end_date2, env = NULL)
data3<- as.ts(data2[,4])
section<-length(data3)/3
#divide subset into 3 sections
subdata1<-data3[1:section]
subdata2<-data3[section:(section*2)]
subdata3<-data3[(section*2):(section*3)]
section2<-length(subdata1)
testdata1<-data1[,4]
testdata2<-testdata1[1:section2]
#Iterate through testdata
len2<-length(subdata1)
while (x < 0.67){
x<-0.66
resize<-approx(seq_along(subdata1), subdata1, n = len2*x)$y
len<-length(resize)
for (i in testdata1){
testdata2<-testdata1[(1+i):(len+i)]
corl<-cor(testdata2, resize)
if (corl>0.6){
maxes<-c(corl, len, i)
#print(maxes)
}
print(len)
}
x<-(x+0.01)
}
whileループの私のX変数は静的のまま変化しません。いつかwhileループが壊れることを考えると奇妙です。長さは、ラインプリント(len)によって明らかに同じままです。whileループ - 変数xは、同様の規模の
何ができるのですか?
このコードに基づいて、whileループを1回だけ実行するとします。 –
私はコーディングに新しいです、あなたはそれを行う方法を教えてくださいできますか? –
'while'ループはどのように実行されますか? 'x'はループの開始時には未定義です。 – spicypumpkin