R/overwrite.R

Defines functions `overwrite`

`overwrite` <- function(objname, content, environment) {
    objname <- gsub("'|\"|[[:space:]]", "", objname)
    if (exists(objname, environment)) {
        environment[[objname]] <- content
    }
    else {
        structure_string <- paste(capture.output(dput(content)), collapse = " ")

        eval(
            parse(text = sprintf(paste(objname, "<- %s"), structure_string)),
            envir = environment
        )
    }
}

Try the admisc package in your browser

Any scripts or data that you put into this service are public.

admisc documentation built on Sept. 12, 2024, 6:27 a.m.