I have a data set with 41 rows and 21 columns. In DF, each row represents energy data in 15 minute interval of the day (from 10am-8pm). each column represents selected days within a month month.
I need to figure out load variability (standard deviation/ mean) b/w two lines in each column using the following equation.
I.e, between the 1st and 2nd; 1st, 2nd and 3rd; 1st-4th; 1st-5th; etc. element of each column.
I keep getting NA values in "lv" and wonder why. The end result, lv should have a dataframe of 41x21, same as df but with load variability.
Also, how do I also get 2.5 and 97.5 percentiles within the loop other than load variability?
x <- df[1:41,1:21]
#calculate load variability
count = 0
i=1{
for (i in 1:41){
count = count+1
mean = sum (x[1:l,])/count
diff = ((x-mean)^2)
lv= sqrt((diff/(count+1)-1)/mean)
i = i+1
}
}
lv
lv ends up with null values (NA).