Skip to content
Prev 8298 / 12125 Next

[R-pkg-devel] Using function with same name as argument as default argument

Hi Andrew and Ivan,

Thanks for the suggestion. Both are good suggestions; better than what I 
have.


Andrews solution:

 > foo <- function (x, schema = schema(x))
 > {
 >      if (missing(schema)) {
 >          rm(schema)
 >          schema <- schema(x)
 >      }
 > }

Ivans:

 > function(x, schema = mypackagename::schema(x))

Both would work in this case. Ivans is a bit cleaner/simpler; Andrews 
appears simpler from a user perspective. Not sure yet which one I will 
use; I am currently leaning towards Ivans solution.

Thanks!
Jan
On 08-08-2022 15:42, Andrew Simmons wrote: