Why does the following not work?
f = function(...) for (i in ...) print(i)
f(1:3)
# Error in f(1:3) : '...' used in an incorrect context
while this work fine
f = function(...) for (i in 1:length(...)) print(...[i])
f(1:3)
# [1] 1
# [1] 2
# [1] 3
It does not work because the ...
object type is not accessible in interpreted code. You need to capture the object as a list as nongkrong showed:
for(i in list(...))
Take a look at the R manual here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With