File: fixupCall.R

package info (click to toggle)
permute 0.8-3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 896 kB
  • ctags: 1
  • sloc: sh: 9; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 654 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
## Non-exported function that can be used to fix up elements of a call
`fixupCall` <- function(object, element, value) {
    ## element must be character! Try to coerce
    element <- as.character(element)     ## Fails if not coercible
    .call <- getElement(object, "call")  ## get call from object
    .ll <- as.list(.call)                ## convert to a list to manipulate
    names(.ll) <- names(.call)           ## set names on the list
    .ll[[element]] <- value              ## set element to value
    .call <- as.call(.ll)                ## convert back to a call
    object$call <- .call                 ## push back into object
    object
}