Skip to content

An update method for lists?

1 message · Mark Bravington

#
There is a function that does this in the 'mvbutils' package, called
'hack':

hack <- function( fun, ...){
  mc <- match.call( expand.dots=FALSE)$...
  for( i in names( mc))
    formals( fun)[[ i]] <- mc[[ i]]
  fun
}

which is a little different to Deepayan's version-- not sure what the
pros & cons of each are. I use 'hack' extensively inside my '.First'
(and in the startup code for 'mvbutils' itself) to change default
parameters in various 'base', 'graphics' and 'utils' functions. Sounds
like this may be fairly common practice.

Mark

Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623