I am using the approxfun() function to get linear interpolation. I want to write a function which takes the results of approxfun() then shifts and scales it by an amount that I specify. I need to be able to call this new function just like I would call any other function.

Simplified version of my attempt:

```
set.seed(42)
x = rnorm(50)
y = rnorm(50, 5, 2)
fhat = approxfun(x, y, rule = 2)

new_function = function(fhat, a, b){

  new_fhat <- (function(fhat, a, b) a * fhat() + b)()

  return(new_fhat)

}

```

I expect the results to be the same as

```
2 * fhat(1) + 3

```

but instead when I run my function

```
new_function(fhat, a = 2, b = 3)

```

I get an error message: 

\*Error in (function(fhat, a, b) a \* fhat() + b)() : 
 argument "a" is missing, with no default\*