Hi everyone, I am trying to read some values into R and then calculate an SST values, but my initial SST loop will not run properly. I keep getting "NA_Real" values. My code is pretty long so I abbreviated it below,
rm(list=ls())
val <- 0
s <- 0
meanval = 0
SST = 0
data<-read.csv("Qpeak Values.csv", header=TRUE)
#read in every value in table
val[1] = data[2,2]
val[2] = data[3,2]
val[3] = data[4,2]
val[4] = data[5,2]
val[5] = data[6,2]
val[6] = data[7,2] #supposed to be 27 values but I edited them out
#loop to calc all SST's (I have 27 values so my code is looping 1:27)
for(i in 1:6){
SST = SST + ((val[i]-mean(val))^2)
}
After this loop I then calculate all my other SST values that not need to be looping. Since this loop above is getting "NA_real" values, my SST values after the loop are not being calculated.
Could I please have some advice on how to fix my loop?