default: change a function's default arguments

Description Usage Arguments Details Value Examples

Description

default() lets you check, and change, a function's default arguments. reset_default() returns the arguments to their original defaults.

Usage

1
2
3
4
5
default(fun)

default(fun) <- value

reset_default(fun)

Arguments

fun

a function

value

a named list of new default arguments for that function

Details

If fun is a function from a package, a function of the same name will be defined in the calling environment (e.g. your workspace). If fun is defined locally, it will be overwritten by the version with the new defaults.

reset_default returns the reset function, rather than modifying it in place, so you'll need to reassign it, as in the example.

Value

default() (without assignment) invisibly returns a pairlist of the current values of the default arguments. It also prints the default arguments, highlighting those that the user has changed from their original defaults.

reset_default() returns the fun, but with the defaults reset to their original values. If fun was a function from a package, the same thing can be achieved by replacing the locally-defined version of the function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# list the default arguments for a function
default(data.frame)

# change one or more of them
default(data.frame) <- list(fix.empty.names = FALSE)
data.frame(1:3)

# reset the defaults
data.frame <- reset_default(data.frame)
data.frame(1:3)

Example output

  - ... = [none]
  - row.names = NULL
  - check.rows = FALSE
  - check.names = TRUE
  - fix.empty.names = TRUE
  - stringsAsFactors = default.stringsAsFactors() 
   
1 1
2 2
3 3
  X1.3
1    1
2    2
3    3

default documentation built on May 2, 2019, 11:19 a.m.

Related to default in default...