Logic of passing missing argument to rep R function

Next function R

tmp <- function(p) rep(0, length.out = p) 

puzzling me since

 > tmp() [1] 0 

I expect an error in the call since p missing. The documentation for rep states that

The rep function is primitive, but the (partial) matching of argument names is performed as for ordinary functions. You can no longer pass a missing argument, for example. length.out.

I do not understand the logic here. Why does rep seem to ignore the lack of p ?

R version 3.0.2 (2013-09-25)

+7
r
source share
1 answer

In the documentation, I see:

The default behavior looks as if the call was

rep (x, times = 1, length.out = NA, each = 1)

But this does not apply to rep.int , which requires a time argument:

 >rep(0,) [1] 0 >rep.int(0,) Error in rep.int(0, ) : argument "times" is missing, with no default 
+5
source share

All Articles