updateBdatNamespace: replace NAMESPACE from 'rBDATPRO' to 'rBDAT'.

View source: R/updateBdatNamespace.R

updateBdatNamespaceR Documentation

replace NAMESPACE from 'rBDATPRO' to 'rBDAT'.

Description

function replaces calls to package 'rBDATPRO' by calls to package 'rBDAT', simply by replacing the package name.

Usage

updateBdatNamespace(inpath = file.choose(), outpath = NULL)

Arguments

inpath

path of file to process

outpath

either a file name or a directory, both or NULL, see details.

Details

This function merely exists to account for the renaming of the package from rBDATPRO (which was internally used for some period of time) to rBDAT. Its sole purpose is to update R-scripts which use rBDATPRO and now should be updated to use rBDAT. Internally, gsub is used.

outpath can be (i) a filename, then the newly generated file is stored under that name in the inpath directory, (ii) a directory, then the inpath-filename is used with prefixed rbdat_, (iii) a complete path (directory name and file name), then this is used to store the file, (iv) NULL, then the inpath is used with prefixed rbdat_ to the inpath filename.

Value

a character holding path and filename of the updated file

Examples

## Not run: 
p <- tempdir()
f <- "rbdatpro.r"
tx <- c("require(rBDATPRO)", "library(rBDATPRO)",
        "rBDATPRO::getDiameter(list(spp=1, D1=30, H=27))")
pf <- file.path(p, f)
writeLines(tx, con=pf)
file.exists(pf)
list.files(p)
# file.show(pf)

## define different output specs
outpath1 <- file.path(tempdir(), "devel/rbdatScript.r")
outpath2 <- p
outpath3 <- "rbdatScript.r"

(updated_file <- updateBdatNamespace(pf, outpath = NULL))
list.files(p)
# file.show(updated_file)

(updated_file <- updateBdatNamespace(pf, outpath1))
list.files(file.path(p, "devel"))
# file.show(updated_file)

(updated_file <- updateBdatNamespace(pf, outpath2))
list.files(p)
# file.show(updated_file)

(updated_file <- updateBdatNamespace(pf, outpath3))
list.files(p)
# file.show(updated_file)

## End(Not run)

rBDAT documentation built on Oct. 14, 2022, 5:07 p.m.