Here are three columns:
indx vehID LocalY 1 2 35.381 2 2 39.381 3 2 43.381 4 2 47.38 5 2 51.381 6 2 55.381 7 2 59.381 8 2 63.379 9 2 67.383 10 2 71.398 11 2 75.401 12 2 79.349 13 2 83.233 14 2 87.043 15 2 90.829 16 2 94.683 17 2 98.611 18 2 102.56 19 2 106.385 20 2 110.079 21 2 113.628 22 2 117.118 23 2 120.6 24 2 124.096 25 2 127.597 26 2 131.099 27 2 134.595 28 2 138.081 29 2 141.578 30 2 145.131 31 2 148.784 32 2 152.559 33 2 156.449 34 2 160.379 35 2 164.277 36 2 168.15 37 2 172.044 38 2 176 39 2 179.959 40 2 183.862 41 2 187.716 42 2 191.561 43 2 195.455 44 2 199.414 45 2 203.417 46 2 207.43 47 2 211.431 48 2 215.428 49 2 219.427 50 2 223.462 51 2 227.422 52 2 231.231 53 2 235.001 54 2 238.909 55 2 242.958 56 2 247.137 57 2 251.247 58 2 255.292 59 2 259.31 60 2 263.372 61 2 267.54 62 2 271.842 63 2 276.256 64 2 280.724 65 2 285.172
I want to create a new Smooth Y column using the following formula: 
D = 15, triangle (triangular symbol) = 5, i = indx, x_alpha (tk) = LocalY, x_alpha (ti) = smoothed value
I tried using the following code for the first calculation of Z: (The core below means the exp function)
t <- 0.5 dt <- 0.1 delta <- t/dt d <- 3*delta indx <- a$indx for (i in indx) { initial <- id end <- i+d k <- c(initial:end) for (n in k) { kernel <- exp(-abs(in)/delta) z <- sum(kernel) } } a$z <- z print (a)
NOTE: βaβ is an imported data frame containing the three columns above.
Although the values ββof the calculated function are accurate, they do not summarize the values ββin the variable z. How can I sum over the range of id to i + d for each indx i value?
r sum
umair durrani
source share