This package provides backports of functions which have been introduced in one of the base packages in R version 3.0.1 or later. The backports are conditionally exported in order to let R resolve the function name to either the implemented backport, or the respective base version, if available. Package developers can make use of new functions or arguments by selectively importing specific backports to support older installations.
Attach the namespace via library(backports)
.
Note that it is crucial that backports
is build against the currently running R version.
Do not ignore these kind of warnings for this package.
Imports
..onLoad()
(see here) to call the import()
function of backports:
r
.onLoad <- function(libname, pkgname) {
backports::import(pkgname)
}
You can also selectively import functions:
r
.onLoad <- function(libname, pkgname) {
backports::import(pkgname, c("get0", "dir.exists"))
}
If you set force = TRUE
, the provided functions will get imported, regardless of the R version:
r
.onLoad <- function(libname, pkgname) {
backports::import(pkgname, "hasName", force = TRUE)
}
Depends
in your DESCRIPTION to require R (>= 3.0.0)
.utils
or tools
Backports for functions which are not in the base
require additional steps.
Usually, you need to to import those functions in the package NAMESPACE.
However, this is only possible if such a function really exists, and yields a warning during R CMD check
for older versions.
There are three possibilities to deal with this:
import(utils)
instead of importFrom(utils, hasName)
in your NAMESPACE
file.NAMESPACE
file, e.g.
if (getRversion() >= "3.4.0") {
importFrom(utils, hasName)
} else {
importFrom(backports, hasName)
}
Note that the braces {}
are necessary in the
NAMESPACE
file, even though they wouldn't be for regular R code, and that you might get a warning
for including backports
in the Imports:
section of your DESCRIPTION
file if you never end up using it.base::anyNA()
base::dir.exists()
base::file.size()
, base::file.mode()
and base::file.mtime()
base::lengths()
extra_cols
for base::file.info()
repeated
for utils::URLencode
base::isNamespaceLoaded()
base::startsWith()
and base::endsWith()
base::strrep()
base::trimws()
type
for utils::capture.output()
base::.valid.factor()
utils::hasName()
base::...length()
base::...elt()
base::isFALSE()
base::warningCondition()
base::errorCondition()
q
for base::dQuote()
and base::sQuote()
tools::vignetteInfo()
base::str2lang()
base::str2expression()
base::asplit()
utils::removeSource()
with the capability to strip source from language objects.base::deparse1()
base::list2DF()
tools::R_user_dir()
classes
for base::suppressWarnings()
and base::suppressMessages()
recycle0
for base::paste()
.recycle0
for base::paste0()
.base::...names()
base::.libPaths()
tools:::print.Rconcordance
tools:::as.character.Rconcordance
tools::as.Rconcordance
tools:::as.Rconcordance.default
tools::matchConcordance
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.