Skip to content
Prev 366179 / 398502 Next

modify the imported version of a function

Figured it out...in case it is useful to others:

    > library(lint)

    > lint.enclos <- parent.env(asNamespace("lint"))

    > stopifnot(all(c("perl", "regex") %in% ls(lint.enclos)))

    > lint.enclos$perl
    function (pattern)
    {
        message("perl is deprecated. Please use regexp instead")
        regex(pattern)
    }
    <environment: namespace:stringr>

    > unlockBinding("perl", lint.enclos)

    > lint.enclos$perl <- lint.enclos$regex

    > lint.enclos$perl
    function (pattern, ignore_case = FALSE, multiline = FALSE, comments 
= FALSE,
        dotall = FALSE, ...)
    {
        options <- stri_opts_regex(case_insensitive = ignore_case,
            multiline = multiline, comments = comments, dotall = dotall,
            ...)
        structure(pattern, options = options, class = c("regex",
            "pattern", "character"))
    }
    <environment: namespace:stringr>
On 12/16/2016 06:06 PM, Benjamin Tyner wrote: