Why there is no error reported when b is not supplied but required inside the function? Thanks!
f2 <- function(a,b) {a[b]}; f2(a=rep(1, 2))
I understand that there is no error in this function:
f <- function(x) {
10
}
f(stop("This is an error!"))
due to lazy evaluation But this
f <- function(x) {
force(x)
10
}
f(stop("This is an error!"))
or this
f <- function(x) {
x
10
}
f(stop("This is an error!"))
will produce an error. Because in both cases x is used within the function. Both the above two examples are from http://adv-r.had.co.nz/Functions.html. Since b is also used within f2, should it be necessary to add force inside f2? Thanks!