I am trying to get my function (in r) to work with a two-element vector as an argument, but when I run the function with inputs, one of the elements is "not found".
I've tried using a placeholder as the argument and defining the placeholder later in the function. I've also tried to use concatenated values directly as the argument.
mse.func <- function(ya.vctr, N=gmp$pop, Y=gmp$pcgmp){ ya.vctr <- c(y, a) mean.sq.er <- mean((Y - (y * (N^a)))^2) return(mean.sq.er) } mse.func(c(5000, 0.10)) I'm expecting a numerical value but mse.func(c(5000, 0.10)) returns an error stating that "object 'y' is not found".
ydefined in your function call. There is also no objecta. Why are you overwriting your vector,ya.vctrwith these values if you're already providing the function call withya.vctrthe value ofc(5000, 0.10)? My guess is you mean to doy <- ya.vctr[1]; a <- ya.vctr[2].