I have the following function:
I would like to write a function in R for f. It should take as arguments x, c1, ..., cn and n.
I have the following function:
I would like to write a function in R for f. It should take as arguments x, c1, ..., cn and n.
If the argument lengths are variable, use 3 dots (...)
f1 <- function(x, ...) {
2 * x + sum((x - c(...))^2)
}
-testing
f1(5, 10, 5, 2, 3)
[1] 48