The logic of passing a missing argument to the R-function rep
r
Solution
In the documentation, I see:
The default behaviour is as if the call was
rep(x, times = 1, length.out = NA, each = 1)
But it does not apply for `rep.int`, which requires times argument:
>rep(0,)
[1] 0
>rep.int(0,)
Error in rep.int(0, ) : argument "times" is missing, with no default
Problem
The following R function ``` tmp <- function(p) rep(0, length.out = p) ``` puzzles me, since ``` > tmp() [1] 0 ``` I would expect an error in the call, since `p` is missing. The documentation for `rep` says that Function rep is a primitive, but (partial) matching of argument names is performed as for normal functions. You can no longer pass a missing argument to e.g. length.out. I don't understand the logic here. Why does `rep` seem to ignore that `p` is missing? R version 3.0.2 (2013-09-25)