i tried to create a custom function which intends to estimate a na-value as the arithemtic average between two non-na-values and set in to the specific na-field in the data(how useful this estimation is shall not be the question here); But somehow my code does not work and i don't understand why, maybe you can help me; Here is the code:
#x == Vector of NA's (e.g.: x = which(is.na(y)))
#y == vector/matrix of Data
interpolate = function(x, y){
  c = length(x)
  for (i in 1:c){
    d       = x[i]
    e       = 1
    success = !is.na(y[d+e])
    while (success = FALSE){
      e = e+1
    }
    if (success = TRUE) {
      y[d] = (y[d-1] + y[d+e])/2
      e = 1
    }
  }
}
It produces three times the error: Unexpected '}' in " }" (...)
 
    