I am trying to solve a system of non-linear equations in R but it keeps giving me this error "number of items to replace is not a multiple of replacement length".

My code looks like this:

```
my_data <- Danske

D <- my_data$D

V <- my_data$V

r <- my_data$r

s <- my_data$s

fnewton <- function(x)
{

  y <- numeric(2)

  d1 <- (log(x[1]/D)+(r+x[2]^2/2))/x[2]

  d2 <- d1-x[2]

  y[1] <- V - (x[1]*pnorm(d1) - exp(-r)*D*pnorm(d2))

  y[2] <- s*V - pnorm(d1)*x[2]*x[1]

  y
}
xstart <- c(239241500000, 0.012396)

nleqslv(xstart, fnewton, method="Newton")

```

D, V, r and s are numeric[1:2508] values and I think thats where the problem comes from. If I have single values 1x1, it solves it well, however, if I insert vectors with 2508 values, it only calculates the first x1 and x2 and then comes the warnings with the message I wrote above.

Thank you for any help.

Lina