backports/0000755000176200001440000000000014155627272012255 5ustar liggesusersbackports/NAMESPACE0000644000176200001440000000400514155620417013465 0ustar liggesusers# Generated by roxygen2: do not edit by hand export(import) if (getRversion() < "3.2.0") export(URLencode) if (getRversion() < "3.2.0") export(anyNA) if (getRversion() < "3.2.0") export(dir.exists) if (getRversion() < "3.2.0") export(file.info) if (getRversion() < "3.2.0") export(file.mode) if (getRversion() < "3.2.0") export(file.mtime) if (getRversion() < "3.2.0") export(file.size) if (getRversion() < "3.2.0") export(get0) if (getRversion() < "3.2.0") export(isNamespaceLoaded) if (getRversion() < "3.2.0") export(lengths) if (getRversion() < "3.2.0") export(trimws) if (getRversion() < "3.3.0") export(capture.output) if (getRversion() < "3.3.0") export(endsWith) if (getRversion() < "3.3.0") export(startsWith) if (getRversion() < "3.3.0") export(strrep) if (getRversion() < "3.4.0") export(.valid.factor) if (getRversion() < "3.4.0") export(hasName) if (getRversion() < "3.5.0") export(...elt) if (getRversion() < "3.5.0") export(...length) if (getRversion() < "3.5.0") export(isFALSE) if (getRversion() < "3.5.0") export(isTRUE) if (getRversion() < "3.6.0") export(asplit) if (getRversion() < "3.6.0") export(dQuote) if (getRversion() < "3.6.0") export(errorCondition) if (getRversion() < "3.6.0") export(removeSource) if (getRversion() < "3.6.0") export(sQuote) if (getRversion() < "3.6.0") export(str2expression) if (getRversion() < "3.6.0") export(str2lang) if (getRversion() < "3.6.0") export(vignetteInfo) if (getRversion() < "3.6.0") export(warningCondition) if (getRversion() < "4.0.0") export(R_user_dir) if (getRversion() < "4.0.0") export(deparse1) if (getRversion() < "4.0.0") export(list2DF) if (getRversion() < "4.0.0") export(stopifnot) if (getRversion() < "4.0.0") export(suppressMessages) if (getRversion() < "4.0.0") export(suppressWarnings) if (getRversion() < "4.0.1") export(paste) if (getRversion() < "4.0.1") export(paste0) if (getRversion() < "4.1.0") export(...names) importFrom(utils,getFromNamespace) importFrom(utils,head) useDynLib(backports,dotsElt) useDynLib(backports,dotsLength) useDynLib(backports,dotsNames) backports/.aspell/0000755000176200001440000000000013636753627013622 5ustar liggesusersbackports/.aspell/backports.rds0000644000176200001440000000012513636753627016322 0ustar liggesusers‹‹àb```b`f’Ì@&ƒ³2°0piޤÄäì‚ü¢(ŸÓ Ê/† $¡ ¥fæ䤿¦æ•$–dæçÁ%ŠÐ%_U¶+zbackports/.aspell/defaults.R0000644000176200001440000000021413636753627015551 0ustar liggesusersRd_files <- vignettes <- R_files <- description <- list(encoding = "UTF-8", language = "en", dictionaries = c("en_stats", "backports")) backports/README.md0000644000176200001440000001043514147213100013515 0ustar liggesusers# backports [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/backports)](https://cran.r-project.org/package=backports) [![R-CMD-check](https://github.com/r-lib/backports/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/backports/actions) [![Download Stats](http://cranlogs.r-pkg.org/badges/backports)](https://cran.r-project.org/package=backports) 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. ## Usage ### Interactively 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. ### In packages 1. Add backports to your DESCRIPTION under `Imports`. 2. Add or modify the function `.onLoad()` (see [here](https://stat.ethz.ch/R-manual/R-devel/library/base/html/ns-hooks.html)) 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) } ``` 3. [Optional] Set `Depends` in your DESCRIPTION to require `R (>= 3.0.0)`. ### Importing backports from `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: 1. Completely import the namespaces instead of selectively importing them, e.g. use `import(utils)` instead of `importFrom(utils, hasName)` in your `NAMESPACE` file. 2. Force-import the function (see above) so that you always use the backport instead of the implementation shipped with R, even for the most recent version of R. 3. Use a conditional import in your `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. ## Backports for R versions prior to 3.2.0 * `base::anyNA()` * `base::dir.exists()` * `base::file.size()`, `base::file.mode()` and `base::file.mtime()` * `base::lengths()` * Argument `extra_cols` for `base::file.info()` * Argument `repeated` for `utils::URLencode` * `base::isNamespaceLoaded()` ## Backports for R versions prior to 3.3.0 * `base::startsWith()` and `base::endsWith()` * `base::strrep()` * `base::trimws()` * Argument `type` for `utils::capture.output()` ## Backports for R versions prior to 3.4.0 * `base::.valid.factor()` * `utils::hasName()` ## Backports for R versions prior to 3.5.0 * `base::...length()` * `base::...elt()` * `base::isFALSE()` ## Backports for R versions prior to 3.6.0 * `base::warningCondition()` * `base::errorCondition()` * Argument `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. ## Backports for R versions prior to 4.0.0 * `base::deparse1()` * `base::list2DF()` * `tools::R_user_dir()` * Argument `classes` for `base::suppressWarnings()` and `base::suppressMessages()` ## Backports for R versions prior to 4.0.1 * Argument `recycle0` for `base::paste()`. * Argument `recycle0` for `base::paste0()`. ## Backports for R versions prior to 4.1.0 * `base::...names()` backports/man/0000755000176200001440000000000014147211264013017 5ustar liggesusersbackports/man/dir.exists.Rd0000644000176200001440000000076313636753630015422 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dir.exists.R \name{dir.exists} \alias{dir.exists} \title{Backport of dir.exists for R < 3.2.0} \usage{ dir.exists(paths) } \description{ See the original description in \code{base::dir.exists}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_dir.exists = getFromNamespace("dir.exists", "backports") bp_dir.exists(tempdir()) } \keyword{internal} backports/man/import.Rd0000644000176200001440000000276713672250602014635 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/import.R \name{import} \alias{import} \title{Import backported functions into your package} \usage{ import(pkgname, obj = NULL, force = FALSE) } \arguments{ \item{pkgname}{[\code{character(1)}]\cr Name of the package where the backported function should be assigned.} \item{obj}{[\code{character}]\cr Name of objects to assign, as character vector. If \code{NULL}, all backports which are not provided by R itself are assigned.} \item{force}{[\code{logical}]\cr If \code{obj} is provided and \code{force} is set to \code{FALSE}, only backports not provided by the base package of the executing R interpreter are imported. Set to \code{TRUE} to ignore this check and always import the backport into the package's namespace.} } \description{ Imports objects from \pkg{backports} into the namespace of other packages by assigning it during load-time. See examples for a code snippet to copy to your package. } \examples{ \dontrun{ # This imports all functions implemented in backports while the package is loaded .onLoad <- function(libname, pkgname) { backports::import(pkgname) } # This only imports the function "trimws" .onLoad <- function(libname, pkgname) { backports::import(pkgname, "trimws") } # This imports all backports from base and force-imports "hasName" from utils .onLoad <- function(libname, pkgname) { backports::import(pkgname) backports::import(pkgname, "hasName", force = TRUE) } } } \seealso{ \code{\link{.onLoad}} } backports/man/file.size.Rd0000644000176200001440000000143313636753630015211 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/file.mode.R, R/file.mtime.R, R/file.size.R \name{file.mode} \alias{file.mode} \alias{file.mtime} \alias{file.size} \title{Backports of wrappers around \code{file.info} for R < 3.2.0} \usage{ file.mode(...) file.mtime(...) file.size(...) } \description{ See the original description in \code{base::file.size}. } \examples{ # get functions from namespace instead of possibly getting # implementations shipped with recent R versions: bp_file.size = getFromNamespace("file.size", "backports") bp_file.mode = getFromNamespace("file.size", "backports") bp_file.mtime = getFromNamespace("file.size", "backports") fn = file.path(R.home(), "COPYING") bp_file.size(fn) bp_file.mode(fn) bp_file.size(fn) } \keyword{internal} backports/man/deparse1.Rd0000644000176200001440000000102113657041607015013 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/deparse1.R \name{deparse1} \alias{deparse1} \title{Backport of deparse1 for R < 4.0.0} \usage{ deparse1(expr, collapse = " ", width.cutoff = 500L, ...) } \description{ See the original description in \code{base::deparse1}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_deparse1 = getFromNamespace("deparse1", "backports") bp_deparse1(quote(`foo bar`)) } \keyword{internal} backports/man/asplit.Rd0000644000176200001440000000074314005747225014612 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/asplit.R \name{asplit} \alias{asplit} \title{Backport of asplit for R < 3.6.0} \usage{ asplit(x, MARGIN) } \description{ See the original description in \code{base::asplit}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_asplit = getFromNamespace("asplit", "backports") x = matrix(1:6, 2, 3) bp_asplit(x, 1) } \keyword{internal} backports/man/file.info.Rd0000644000176200001440000000113313636753630015167 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/file.info.R \name{file.info} \alias{file.info} \title{Backport of \code{file.info} for R < 3.2.0} \usage{ file.info(..., extra_cols = TRUE) } \description{ Argument \code{extra_cols} has been backported. See the original description in \code{base::file.info}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_file.info = getFromNamespace("file.info", "backports") bp_file.info(file.path(R.home(), "COPYING"), extra_cols = FALSE) } \keyword{internal} backports/man/isFALSE.Rd0000644000176200001440000000074113636753630014510 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/isFALSE.R \name{isFALSE} \alias{isFALSE} \title{Backport of isFALSE for R < 3.4.2} \usage{ isFALSE(x) } \description{ See the original description in \code{base::isFALSE}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_isFALSE = getFromNamespace("isFALSE", "backports") bp_isFALSE(FALSE) bp_isFALSE(iris) } \keyword{internal} backports/man/URLencode.Rd0000644000176200001440000000115513636753630015142 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/URLencode.R \name{URLencode} \alias{URLencode} \title{Backport of URLencode for R < 3.2.0} \usage{ URLencode(URL, reserved = FALSE, repeated = FALSE) } \description{ See the original description in \code{utils::URLencode}. Argument \code{repeated} is backported. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_URLencode = getFromNamespace("URLencode", "backports") URLdecode(z <- "ab\%20cd") c(bp_URLencode(z), bp_URLencode(z, repeated = TRUE)) } \keyword{internal} backports/man/suppressWarnings.Rd0000644000176200001440000000142213730224071016677 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/suppressWarnings.R \name{suppressWarnings} \alias{suppressWarnings} \alias{suppressMessages} \title{Backport of suppressWarnings and suppressMessages for R < 4.0.0} \usage{ suppressWarnings(expr, classes = "warning") suppressMessages(expr, classes = "message") } \description{ Backport for new argument `classes`. See the original description in \code{base::suppressWarnings}/\code{base::suppressMessages}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_suppressWarnings = getFromNamespace("suppressWarnings", "backports") bp_suppressWarnings(warningCondition("warning", class = "testWarning"), "testWarning") } \keyword{internal} backports/man/list2DF.Rd0000644000176200001440000000130314147211264014552 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/list2DF.R \name{list2DF} \alias{list2DF} \title{Backport of list2DF for R < 4.0.0} \usage{ list2DF(x = list(), nrow = 0L) } \description{ See the original description in \code{base::list2DF}. Note that the behaviour of \code{list2DF()} changed in R 4.2.0. Instead of recycling vectors to common length, an exception is raised. This backport implements the new behaviour, throwing an error message. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_list2DF = getFromNamespace("list2DF", "backports") bp_list2DF(list(x = 1:3, y = 2:4)) } \keyword{internal} backports/man/endsWith.Rd0000644000176200001440000000076313636753630015113 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/endsWith.R \name{endsWith} \alias{endsWith} \title{Backport of endsWith for R < 3.3.0} \usage{ endsWith(x, suffix) } \description{ See the original description in \code{base::endsWith}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_endsWith = getFromNamespace("endsWith", "backports") bp_endsWith(c("aabb", "bbcc"), "bb") } \keyword{internal} backports/man/startsWith.Rd0000644000176200001440000000100513636753630015470 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/startsWith.R \name{startsWith} \alias{startsWith} \title{Backport of startsWith for R < 3.3.0} \usage{ startsWith(x, prefix) } \description{ See the original description in \code{base::startsWith}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_startsWith = getFromNamespace("startsWith", "backports") bp_startsWith(c("aabb", "bbcc"), "bb") } \keyword{internal} backports/man/warningCondition.Rd0000644000176200001440000000132513636753630016635 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/warningCondition.R \name{warningCondition} \alias{warningCondition} \alias{errorCondition} \title{Backport of warningCondition and errorCondition for R < 3.6.0} \usage{ warningCondition(msg, ..., class = NULL, call = NULL) errorCondition(msg, ..., class = NULL, call = NULL) } \description{ See the original description in \code{base::warningCondition}/\code{base::errorCondition}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_warningCondition = getFromNamespace("warningCondition", "backports") bp_warningCondition("package backports not found") } \keyword{internal} backports/man/str2expression.Rd0000644000176200001440000000102513722007576016325 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/str2expression.R \name{str2expression} \alias{str2expression} \title{Backport of str2expression for R < 3.6.0} \usage{ str2expression(text) } \description{ See the original description in \code{base::str2expression}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: str2expression <- getFromNamespace("str2expression", "backports") str2expression("x[3] <- 1+4") } \keyword{internal} backports/man/get0.Rd0000644000176200001440000000110013642106266014141 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/get0.R \name{get0} \alias{get0} \title{Backport of get0 for R < 3.2.0} \usage{ get0( x, envir = pos.to.env(-1L), mode = "any", inherits = TRUE, ifnotfound = NULL ) } \description{ See the original description in \code{base::get0}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_get0 = getFromNamespace("get0", "backports") bp_get0("a") bp_get0("a", ifnotfound = 0) foo = 12 bp_get0("foo") } \keyword{internal} backports/man/paste.Rd0000644000176200001440000000104314147211370014416 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/paste.R \name{paste} \alias{paste} \title{Backport of paste for R < 4.0.1} \usage{ paste(..., sep = " ", collapse = NULL, recycle0 = FALSE) } \description{ See the original description in \code{base::paste}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_paste = getFromNamespace("paste", "backports") bp_paste(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) } \keyword{internal} backports/man/dotsLength.Rd0000644000176200001440000000077613636753630015445 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dotsLength.R \name{...length} \alias{...length} \title{Backport of ...length for R < 3.4.2} \usage{ ...length() } \description{ See the original description in \code{base::...length}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_...length = getFromNamespace("...length", "backports") foo = function(...) bp_...length() foo(1, 2, 3) } \keyword{internal} backports/man/lengths.Rd0000644000176200001440000000075113636753630014767 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lengths.R \name{lengths} \alias{lengths} \title{Backport of lengths for R < 3.2.0} \usage{ lengths(x, use.names = TRUE) } \description{ See the original description in \code{base::lengths}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_lengths = getFromNamespace("lengths", "backports") bp_lengths(list(1:3, 2)) } \keyword{internal} backports/man/valid.factor.Rd0000644000176200001440000000103013636753630015666 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/valid.factor.R \name{.valid.factor} \alias{.valid.factor} \title{Backport of .valid.factor for R < 3.4.0} \usage{ .valid.factor(object) } \description{ See the original description in \code{base::.valid.factor}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_.valid_factor = getFromNamespace(".valid.factor", "backports") bp_.valid_factor(factor(letters[1:3])) } \keyword{internal} backports/man/vignetteInfo.Rd0000644000176200001440000000075113672250205015752 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignetteInfo.R \name{vignetteInfo} \alias{vignetteInfo} \title{Backport of vignetteInfo for R < 3.6.0} \usage{ vignetteInfo(file) } \description{ See the original description in \code{tools::vignetteInfo}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_vignetteInfo = getFromNamespace("vignetteInfo", "backports") } \keyword{internal} backports/man/isNamespaceLoaded.Rd0000644000176200001440000000106314005747225016653 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/isNamespaceLoaded.R \name{isNamespaceLoaded} \alias{isNamespaceLoaded} \title{Backport of isNamespaceLoaded for R < 3.2.0} \usage{ isNamespaceLoaded(name) } \description{ See the original description in \code{base::isNamespaceLoaded}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_isNamespaceLoaded = getFromNamespace("isNamespaceLoaded", "backports") bp_isNamespaceLoaded("backports") } \keyword{internal} backports/man/backports-package.Rd0000644000176200001440000000172314147211264016672 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/zzz.R \docType{package} \name{backports-package} \alias{backports} \alias{backports-package} \title{backports: Reimplementations of Functions Introduced Since R-3.0.0} \description{ Functions introduced or changed since R v3.0.0 are re-implemented in this package. 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. } \seealso{ Useful links: \itemize{ \item \url{https://github.com/r-lib/backports} \item Report bugs at \url{https://github.com/r-lib/backports/issues} } } \author{ \strong{Maintainer}: Michel Lang \email{michellang@gmail.com} (\href{https://orcid.org/0000-0001-9754-0393}{ORCID}) Authors: \itemize{ \item R Core Team } } backports/man/paste0.Rd0000644000176200001440000000104114147211370014474 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/paste0.R \name{paste0} \alias{paste0} \title{Backport of paste0 for R < 4.0.1} \usage{ paste0(..., collapse = NULL, recycle0 = FALSE) } \description{ See the original description in \code{base::paste0}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_paste0 = getFromNamespace("paste0", "backports") bp_paste0(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) } \keyword{internal} backports/man/R_user_dir.Rd0000644000176200001440000000103613642106266015407 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/R_user_dir.R \name{R_user_dir} \alias{R_user_dir} \title{Backport of R_user_dir for R < 4.0.0} \usage{ R_user_dir(package, which = c("data", "config", "cache")) } \description{ See the original description in \code{tools::R_user_dir}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_R_user_dir = getFromNamespace("R_user_dir", "backports") bp_R_user_dir("backports") } \keyword{internal} backports/man/str2lang.Rd0000644000176200001440000000073413722007576015055 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/str2lang.R \name{str2lang} \alias{str2lang} \title{Backport of str2lang for R < 3.6.0} \usage{ str2lang(s) } \description{ See the original description in \code{base::str2lang}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: str2lang <- getFromNamespace("str2lang", "backports") str2lang("x[3] <- 1+4") } \keyword{internal} backports/man/dotsElt.Rd0000644000176200001440000000076513636753630014746 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dotsElt.R \name{...elt} \alias{...elt} \title{Backport of ...elt for R < 3.4.2} \usage{ ...elt(n) } \description{ See the original description in \code{base::...elt}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_...elt = getFromNamespace("...elt", "backports") foo = function(n, ...) bp_...elt(n) foo(n = 2, "a", "b", "c") } \keyword{internal} backports/man/stopifnot.Rd0000644000176200001440000000112714147211264015334 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stopifnot.R \name{stopifnot} \alias{stopifnot} \title{Backport of stopifnot for R versions < 4.0.0.} \usage{ stopifnot(..., exprs, exprObject, local = TRUE) } \description{ See the original description in \code{base::stopifnot}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_stopifnot = getFromNamespace("stopifnot", "backports") m <- matrix(c(1, 3, 12, 1), 2, 2) \dontrun{bp_stopifnot("m must be symmetric" = m == t(m))} } \keyword{internal} backports/man/removeSource.Rd0000644000176200001440000000077614147211264015776 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/removeSource.R \name{removeSource} \alias{removeSource} \title{Backport of removeSource for R < 3.6.0} \usage{ removeSource(fn) } \description{ See the original description in \code{utils::removeSource}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_removeSource = getFromNamespace("removeSource", "backports") bp_removeSource(mean) } \keyword{internal} backports/man/dotsNames.Rd0000644000176200001440000000077514147211264015254 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dotsNames.R \name{...names} \alias{...names} \title{Backport of ...names for R < 4.1.0} \usage{ ...names() } \description{ See the original description in \code{base::...names}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_...names = getFromNamespace("...names", "backports") foo = function(...) bp_...names() foo(a = 1, b = 2, 3) } \keyword{internal} backports/man/hasName.Rd0000644000176200001440000000076613636753630014705 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/hasName.R \name{hasName} \alias{hasName} \title{Backport of hasName for R < 3.4.0} \usage{ hasName(x, name) } \description{ See the original description in \code{utils::hasName}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_hasName = getFromNamespace("hasName", "backports") bp_hasName(list(a = 1, b = 2), c("a", "b", "c")) } \keyword{internal} backports/man/capture.output.Rd0000644000176200001440000000131413642106266016313 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/capture.output.R \name{capture.output} \alias{capture.output} \title{Backport of capture.output for R < 3.3.0} \usage{ capture.output( ..., file = NULL, append = FALSE, type = c("output", "message"), split = FALSE ) } \description{ Argument \code{type} has been backported. See the original description in \code{utils::capture.output}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_capture.output <- getFromNamespace("capture.output", "backports") captured <- bp_capture.output({ message("hi") }, type = "message") str(captured) } \keyword{internal} backports/man/isTRUE.Rd0000644000176200001440000000121013636753630014425 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/isTRUE.R \name{isTRUE} \alias{isTRUE} \title{Backport of isTRUE for R < 3.5.0} \usage{ isTRUE(x) } \description{ The implementation of `isTRUE` has been changed in R-3.5.0 from \code{identical(x, TRUE)} to \code{is.logical(x) && length(x) == 1L && !is.na(x) && x}. This backport overloads the old implementation for R versions prior to 3.5.0. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_isTRUE = getFromNamespace("isTRUE", "backports") bp_isTRUE(FALSE) bp_isTRUE(iris) } \keyword{internal} backports/man/dQuote.Rd0000644000176200001440000000121413642106266014551 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dQuote.R \name{dQuote} \alias{dQuote} \alias{sQuote} \title{Backport of dQuote and sQuote for R < 3.6.0} \usage{ dQuote(x, q = getOption("useFancyQuotes")) sQuote(x, q = getOption("useFancyQuotes")) } \description{ Argument \code{q} has been backported. See the original description in \code{base::dQuote()} and \code{base::sQuote()}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_dQuote <- getFromNamespace("dQuote", "backports") bp_dQuote("foo") bp_dQuote("foo", q = TRUE) } \keyword{internal} backports/man/strrep.Rd0000644000176200001440000000072013636753630014636 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/strrep.R \name{strrep} \alias{strrep} \title{Backport of strrep for R < 3.3.0} \usage{ strrep(x, times) } \description{ See the original description in \code{base::strrep}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_strrep = getFromNamespace("strrep", "backports") bp_strrep("-", 10) } \keyword{internal} backports/man/anyNA.Rd0000644000176200001440000000073513636753630014333 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/anyNA.R \name{anyNA} \alias{anyNA} \title{Backport of anyNA for R versions < 3.2.0.} \usage{ anyNA(x, recursive = FALSE) } \description{ See the original description in \code{base::anyNA}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_anyNA = getFromNamespace("anyNA", "backports") bp_anyNA(letters) } \keyword{internal} backports/man/trimws.Rd0000644000176200001440000000106213636753630014644 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/trimws.R \name{trimws} \alias{trimws} \title{Backport of trimws for R < 3.3.0} \usage{ trimws(x, which = c("both", "left", "right")) } \description{ See the original description in \code{base::trimws}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_trimws = getFromNamespace("trimws", "backports") bp_trimws(c(" a ", "b ", " c")) bp_trimws(c(" a ", "b ", " c"), which = "left") } \keyword{internal} backports/DESCRIPTION0000644000176200001440000000223514155627272013765 0ustar liggesusersPackage: backports Type: Package Title: Reimplementations of Functions Introduced Since R-3.0.0 Version: 1.4.1 Authors@R: c( person("Michel", "Lang", NULL, "michellang@gmail.com", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-9754-0393")), person("R Core Team", role = "aut")) Maintainer: Michel Lang Description: Functions introduced or changed since R v3.0.0 are re-implemented in this package. 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. URL: https://github.com/r-lib/backports BugReports: https://github.com/r-lib/backports/issues License: GPL-2 | GPL-3 NeedsCompilation: yes ByteCompile: yes Depends: R (>= 3.0.0) Encoding: UTF-8 RoxygenNote: 7.1.2 Packaged: 2021-12-13 10:49:30 UTC; michel Author: Michel Lang [cre, aut] (), R Core Team [aut] Repository: CRAN Date/Publication: 2021-12-13 11:30:02 UTC backports/tests/0000755000176200001440000000000014155621676013421 5ustar liggesusersbackports/tests/test_isNamespaceLoaded.R0000644000176200001440000000024114005747225020132 0ustar liggesuserssource("helper/helper.R") expect_true(isNamespaceLoaded("base")) expect_true(isNamespaceLoaded("backports")) expect_false(isNamespaceLoaded("..notexisting..")) backports/tests/test_str2expression.R0000644000176200001440000000043713722007576017615 0ustar liggesuserssource("helper/helper.R") if (exists("str2expression", envir = baseenv())) { f = get("str2expression", envir = baseenv()) expect_same = makeCompareFun(f, backports:::str2expression) expect_same("x[3] <- 1+4") expect_same("log(y)") expect_same("abc") expect_same("1.375") } backports/tests/test_capture.output.R0000644000176200001440000000071013636753630017602 0ustar liggesuserssource("helper/helper.R") f = get("capture.output", envir = getNamespace("utils")) expect_same = makeCompareFun(f, backports:::capture.output) output = function() { print("stdout") message("stderr") } suppressMessages({ expect_same(output()) }) if (getRversion() >= "3.3.0") { suppressMessages({ expect_same(output(), type = "message") expect_same(output(), type = "output") }) expect_same(output(), type = c("message", "output")) } backports/tests/test_warningCondition.R0000644000176200001440000000110613636753630020114 0ustar liggesuserssource("helper/helper.R") if (exists("warningCondition", envir = baseenv())) { f = get("warningCondition", envir = baseenv()) expect_same = makeCompareFun(f, backports:::warningCondition) expect_same("warning from backports test") expect_same("warning from backports test", class = "test_warning") } if (exists("errorCondition", envir = baseenv())) { f = get("errorCondition", envir = baseenv()) expect_same = makeCompareFun(f, backports:::errorCondition) expect_same("error from backports test") expect_same("error from backports test", class = "test_error") } backports/tests/test_dotsNames.R0000644000176200001440000000065214155621676016543 0ustar liggesuserssource("helper/helper.R") wb = function(...) backports:::...names() if (exists("...names", envir = baseenv()) && getRversion() > "4.1.2") { f = get("...names", envir = baseenv()) wf = function(...) f() expect_same = makeCompareFun(wf, wb) expect_same(1, 2) expect_same(a = 1) expect_same(1, b = 2) expect_same() expect_identical(wb(a = 1, 2), c("a", "")) } expect_identical(wb(a = 1, b = 2), c("a", "b")) backports/tests/test_file.mtime.R0000644000176200001440000000037013636753630016633 0ustar liggesuserssource("helper/helper.R") if (exists("file.mtime", envir = baseenv())) { f = get("file.mtime", envir = baseenv()) expect_same = makeCompareFun(f, backports:::file.mtime) expect_same(R.home()) expect_same(file.path(R.home(), "COPYING")) } backports/tests/helper/0000755000176200001440000000000014005747225014671 5ustar liggesusersbackports/tests/helper/helper.R0000644000176200001440000000156314005747225016300 0ustar liggesuserslibrary(backports) expect_identical = function(x, y) { stopifnot(identical(x, y)) } expect_true = function(x) { stopifnot(isTRUE(x)) } expect_false = function(x) { stopifnot(isFALSE(x)) } expect_error = function(x, pattern = NULL) { ok = try(eval.parent(substitute(x)), silent = TRUE) if (!inherits(ok, "try-error")) stop(deparse(substitute(x)), " did not throw an error") if (!is.null(pattern) && !grepl(pattern, as.character(ok))) stop(sprintf("Expected error message matching '%s', got '%s'", pattern, backports:::trimws(as.character(ok)))) } makeCompareFun = function(f1, f2, ...) { f1 = match.fun(f1) f2 = match.fun(f2) function(...) { r1 = try(f1(...), silent = TRUE) r2 = try(f2(...), silent = TRUE) if (inherits(r1, "try-error")) { stopifnot(inherits(r2, "try-error")) } else { expect_identical(r1, r2) } } } backports/tests/test_strrep.R0000644000176200001440000000201013636753630016112 0ustar liggesuserssource("helper/helper.R") if (exists("strrep", envir = baseenv())) { f = get("strrep", envir = baseenv()) expect_same = makeCompareFun(f, backports:::strrep) expect_same(NULL, 0) expect_same(NULL, 1) expect_same(NULL, 2) expect_same(NULL, 1:2) expect_same(character(0), 0) expect_same(character(0), 1) expect_same(character(0), 2) expect_same(character(0), 1:2) expect_same("", 0) expect_same("", 1) expect_same("", 2) expect_same("", 1:2) expect_same("a", 0) expect_same("a", 1) expect_same("a", 2) expect_same("a", 1:2) expect_same(NA, 0) expect_same(NA, 1) expect_same(NA, 1:2) expect_same(NA_character_, 0) expect_same(NA_character_, 1) expect_same(NA_character_, 2) expect_same(NA_character_, 1:2) expect_same(letters[1:2], 0) expect_same(letters[1:2], 1) expect_same(letters[1:2], 2) expect_same(letters[2:2], 1:2) expect_same(TRUE, 0) expect_same(TRUE, 1) expect_same(TRUE, 2) expect_same(TRUE, 1:2) expect_same("a", NA) expect_same("a", c(1, NA, 2)) } backports/tests/test_file.info.R0000644000176200001440000000056413636753630016460 0ustar liggesuserssource("helper/helper.R") x = tempdir() res1 = backports:::file.info(x, extra_cols = TRUE) res2 = backports:::file.info(x, extra_cols = FALSE) stopifnot(is.data.frame(res1), nrow(res1) == 1L, ncol(res1) >= 7L) stopifnot(is.data.frame(res2), nrow(res2) == 1L, ncol(res2) == 6L) expect_identical(res1, base::file.info(x)) expect_identical(res1[, 1:6, drop = FALSE], res2) backports/tests/test_trimws.R0000644000176200001440000000064513636753630016134 0ustar liggesuserssource("helper/helper.R") if (exists("trimws", envir = baseenv())) { f = get("trimws", envir = baseenv()) expect_same = makeCompareFun(f, backports:::trimws) expect_same("") expect_same(NA) expect_same(NA_character_) expect_same(sprintf(" %s ", letters)) expect_same(" x ") expect_same(" x ", which = "both") expect_same(" x ", which = "left") expect_same(" x ", which = "right") expect_same(1) } backports/tests/test_asplit.R0000644000176200001440000000046214005747225016072 0ustar liggesuserssource("helper/helper.R") if (exists("asplit", envir = baseenv())) { f = get("asplit", envir = baseenv()) expect_same = makeCompareFun(f, backports:::asplit) d <- 2 : 4 x <- array(seq_len(prod(d)), d) expect_same(x, 2) expect_same(x, c(1, 2)) x <- matrix(1 : 6, 2, 3) expect_same(x, 1) } backports/tests/test_hasName.R0000644000176200001440000000047313636753630016162 0ustar liggesuserssource("helper/helper.R") if (exists("hasName", envir = getNamespace("utils"))) { f = get("hasName", envir = getNamespace("utils")) expect_same = makeCompareFun(f, backports:::hasName) x = list(1, a = 12, bbb = 99) expect_same(x, "a") expect_same(x, "c") expect_same(x, "bbb") expect_same(x, "b") } backports/tests/test_removeSource.R0000644000176200001440000000034414005747225017253 0ustar liggesuserssource("helper/helper.R") if (exists("removeSource", envir = getNamespace("utils"))) { f = get("removeSource", envir = getNamespace("utils")) expect_same = makeCompareFun(f, backports:::removeSource) expect_same(mean) } backports/tests/test_deparse1.R0000644000176200001440000000054213657041607016304 0ustar liggesuserssource("helper/helper.R") if (exists("deparse1", envir = baseenv())) { f = get("deparse1", envir = baseenv()) expect_same = makeCompareFun(f, backports:::deparse1) expect_same(args(stats::lm)) e = quote(`foo bar`) expect_same(e) expect_same(e, backtick = TRUE) e = quote(`foo bar`+1) expect_same(e) expect_same(e, control = "all") } backports/tests/test_lengths.R0000644000176200001440000000047113636753630016250 0ustar liggesuserssource("helper/helper.R") if (exists("lengths", envir = baseenv())) { f = get("lengths", envir = baseenv()) expect_same = makeCompareFun(f, backports:::lengths) expect_same(1:3) expect_same(setNames(1:3, letters[1:3])) expect_same(setNames(1:3, letters[1:3]), use.names = FALSE) expect_same(iris) } backports/tests/test_isTRUE.R0000644000176200001440000000035313636753630015716 0ustar liggesuserssource("helper/helper.R") f = backports:::isTRUE expect_identical(f(TRUE), TRUE) expect_identical(f(FALSE), FALSE) expect_identical(f(1), FALSE) expect_identical(f(iris), FALSE) expect_identical(f(structure(TRUE, foo = "bar")), TRUE) backports/tests/test_R_user_dir.R0000644000176200001440000000054713642106266016677 0ustar liggesuserssource("helper/helper.R") if (exists("R_user_dir", envir = asNamespace("tools"))) { f = get("R_user_dir", envir = asNamespace("tools")) expect_same = makeCompareFun(f, backports:::R_user_dir) expect_same("backports") expect_same("backports", which = "data") expect_same("backports", which = "config") expect_same("backports", which = "cache") } backports/tests/test_str2lang.R0000644000176200001440000000041513722007576016333 0ustar liggesuserssource("helper/helper.R") if (exists("str2lang", envir = baseenv())) { f = get("str2lang", envir = baseenv()) expect_same = makeCompareFun(f, backports:::str2lang) expect_same("x[3] <- 1+4") expect_same("log(y)") expect_same("abc") expect_same("1.375") } backports/tests/test_anyNA.R0000644000176200001440000000061113636753630015606 0ustar liggesuserssource("helper/helper.R") if (exists("anyNA", envir = baseenv())) { f = get("anyNA", envir = baseenv()) expect_same = makeCompareFun(f, backports:::anyNA) expect_same(1) expect_same(NA) expect_same(iris) if (getRversion() >= "3.2.0") { expect_same(list(1, 2, list(3, 4, list(NA))), recursive = FALSE) expect_same(list(1, 2, list(3, 4, list(NA))), recursive = TRUE) } } backports/tests/test_file.size.R0000644000176200001440000000036513636753630016476 0ustar liggesuserssource("helper/helper.R") if (exists("file.size", envir = baseenv())) { f = get("file.size", envir = baseenv()) expect_same = makeCompareFun(f, backports:::file.size) expect_same(R.home()) expect_same(file.path(R.home(), "COPYING")) } backports/tests/test_dQuote.R0000644000176200001440000000067013642106451016034 0ustar liggesuserssource("helper/helper.R") f = get("dQuote", envir = baseenv()) expect_same = makeCompareFun(f, backports:::dQuote) expect_same("foo") if (getRversion() >= "3.6.0") { expect_same("foo", q = TRUE) expect_same("foo", q = FALSE) } f = get("sQuote", envir = baseenv()) expect_same = makeCompareFun(f, backports:::sQuote) expect_same("foo") if (getRversion() > "3.6.0") { expect_same("foo", q = TRUE) expect_same("foo", q = FALSE) } backports/tests/test_file.mode.R0000644000176200001440000000036513636753630016450 0ustar liggesuserssource("helper/helper.R") if (exists("file.mode", envir = baseenv())) { f = get("file.mode", envir = baseenv()) expect_same = makeCompareFun(f, backports:::file.mode) expect_same(R.home()) expect_same(file.path(R.home(), "COPYING")) } backports/tests/test_dotsElt.R0000644000176200001440000000101213636753630016212 0ustar liggesuserssource("helper/helper.R") wb = function(n, ...) backports:::...elt(n) if (exists("...elt", envir = baseenv())) { f = get("...elt", envir = baseenv()) wf = function(n, ...) f(n) expect_same = makeCompareFun(wf, wb) expect_same(1, 1, 2, 3) expect_same(2, 1, 2, 3) expect_same(3, 1, 2, 3) } expect_identical(wb(1, "a", "b", "c"), "a") expect_identical(wb(2, "a", "b", "c"), "b") expect_identical(wb(3, "a", "b", "c"), "c") expect_error(wb(0, "a"), "non-positive") expect_error(wb(2, "a"), "does not contain") backports/tests/test_valid.factor.R0000644000176200001440000000124113636753630017154 0ustar liggesuserssource("helper/helper.R") f = backports:::.valid.factor x = factor(letters[1:3]) expect_identical(f(x), TRUE) x = 1:2 attr(x, "levels") = c("a", "a") expect_true(is.character(.valid.factor(x))) if (exists(".valid.factor", envir = baseenv())) { f = get(".valid.factor", envir = baseenv()) expect_same = makeCompareFun(f, backports:::.valid.factor) expect_same(letters[1:2]) expect_same(NULL) expect_same(iris) expect_same(factor("a")) expect_same(factor(1:3, levels = 1:3)) x = 1:2 class(x) = "factor" attr(x, "levels") = c("a", "b") expect_same(x) attr(x, "levels") = c("a", "a") expect_same(x) attr(x, "levels") = 1:2 expect_same(x) } backports/tests/test_isFALSE.R0000644000176200001440000000035513636753630015773 0ustar liggesuserssource("helper/helper.R") f = backports:::isFALSE expect_identical(f(FALSE), TRUE) expect_identical(f(TRUE), FALSE) expect_identical(f(1), FALSE) expect_identical(f(iris), FALSE) expect_identical(f(structure(FALSE, foo = "bar")), TRUE) backports/tests/test_suppressWarnings.R0000644000176200001440000000043413730224170020163 0ustar liggesuserssource("helper/helper.R") if (getRversion() >= "4.0.0") { f = get("suppressWarnings", envir = baseenv()) expect_same = makeCompareFun(f, backports:::suppressWarnings) expect_same(suppressWarnings(backports:::warningCondition("foo", "testWarning")), classes = "testWarning") } backports/tests/test_get0.R0000644000176200001440000000151213636753630015440 0ustar liggesuserssource("helper/helper.R") if (exists("get0", envir = baseenv())) { f = get("get0", envir = baseenv()) expect_same = makeCompareFun(f, backports:::get0) foo = 1 ee = new.env() ee$bar = 1 ee$foobar = function(x) x^2 expect_same(character(0), ifnotfound = 1) expect_same(NA_character_, ifnotfound = 1) expect_same(factor("a"), ifnotfound = 1) expect_same("bar") expect_same("bar", ifnotfound = 42) expect_same("foo") expect_same("foo", ifnotfound = 42) expect_same(c("foo", "bar", "iris"), ifnotfound = 42) expect_same(c("bar", "foo", "iris"), ifnotfound = 42) expect_same(c("iris", "foo", "bar"), ifnotfound = 42) expect_same("bar", envir = ee) expect_same("bar", envir = ee, mode = "function") expect_same("bar", envir = ee, mode = "function") expect_same("foobar", envir = ee, mode = "function") } backports/tests/test_paste.R0000644000176200001440000000475714147211264015721 0ustar liggesuserssource("helper/helper.R") if (getRversion() >= "4.0.0") { f = get("paste", envir = baseenv()) expect_same = makeCompareFun(f, backports:::paste) expect_same(letters[1:3], character()) expect_same(letters[1:3], character(), recycle0 = TRUE) expect_same(letters[1:3], character(), sep = "_", recycle0 = TRUE) expect_same(letters[1:3], character(), sep = "_", collapse = "+", recycle0 = TRUE) expect_same(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) expect_same(letters[1:3], character(), sep = NULL, recycle0 = TRUE) expect_same(letters[1:3], character(), sep = NULL, collapse = NULL, recycle0 = TRUE) expect_same(letters[1:3], character(), sep = character(), collapse = character(), recycle0 = TRUE) expect_same(character()) expect_same(character(), recycle0 = TRUE) expect_same(character(), sep = "_", recycle0 = TRUE) expect_same(character(), sep = "_", collapse = "+", recycle0 = TRUE) expect_same(character(), collapse = NULL, recycle0 = TRUE) expect_same(character(), sep = NULL, recycle0 = TRUE) expect_same(character(), sep = NULL, collapse = NULL, recycle0 = TRUE) expect_same(character(), sep = character(), collapse = character(), recycle0 = TRUE) f = get("paste0", envir = baseenv()) expect_same = makeCompareFun(f, backports:::paste0) expect_same(letters[1:3], character()) expect_same(letters[1:3], character(), recycle0 = TRUE) expect_same(letters[1:3], character(), recycle0 = TRUE) expect_same(letters[1:3], character(), collapse = "+", recycle0 = TRUE) expect_same(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) expect_same(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) expect_same(letters[1:3], character(), collapse = character(), recycle0 = TRUE) expect_same(character()) expect_same(character(), recycle0 = TRUE) expect_same(character(), recycle0 = TRUE) expect_same(character(), collapse = "+", recycle0 = TRUE) expect_same(character(), collapse = NULL, recycle0 = TRUE) expect_same(character(), collapse = NULL, recycle0 = TRUE) expect_same(character(), collapse = character(), recycle0 = TRUE) } expect_identical( paste(letters[1:3], character(), collapse = NULL, recycle0 = TRUE), character() ) expect_identical( paste(letters[1:3], character(), collapse = "_", recycle0 = TRUE), "" ) expect_identical( paste0(letters[1:3], character(), collapse = NULL, recycle0 = TRUE), character() ) expect_identical( paste0(letters[1:3], character(), collapse = "_", recycle0 = TRUE), "" ) backports/tests/test_startsWith.R0000644000176200001440000000412313636753630016756 0ustar liggesuserssource("helper/helper.R") if (exists("startsWith", envir = baseenv())) { f = get("startsWith", envir = baseenv()) expect_same = makeCompareFun(f, backports:::startsWith) expect_same("a", "a") expect_same(NA, "a") expect_same("a", NA) expect_same("a", "") expect_same("", "a") expect_same("", "") expect_same(c("a", NA, "b"), "b") expect_same("b", c("a", NA, "b")) expect_same(letters, c("m", NA, "")) } if (exists("endsWith", envir = baseenv())) { f = get("endsWith", envir = baseenv()) expect_same = makeCompareFun(f, backports:::endsWith) expect_same("a", "a") expect_same(NA, "a") expect_same("a", NA) expect_same("a", "") expect_same("", "a") expect_same("", "") expect_same(c("a", NA, "b"), "b") expect_same("b", c("a", NA, "b")) expect_same(letters, c("m", NA, "")) } # adapted from R's unit tests t1 = c("Foobar", "bla bla", "something", "another", "blu", "brown", "blau blüht der Enzian") t2 = c("some text", "any text") t3 = c("Martin", "Zürich", "Mächler") expect_true(all(backports:::startsWith(t1, ""))) expect_true(all(backports:::endsWith(t1, ""))) expect_true(all(backports:::endsWith(t2, ""))) expect_true(all(backports:::startsWith(t2, ""))) expect_true(all(backports:::endsWith(t3, ""))) expect_true(all(backports:::startsWith(t3, ""))) expect_true(all(backports:::endsWith(t2, "text"))) expect_true(all(backports:::endsWith(t2, " text"))) expect_identical(backports:::startsWith(t1, "b" ), c(FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE)) expect_identical(backports:::startsWith(t1, "bl"), c(FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE)) expect_identical(backports:::startsWith(t1, "bla"),c(FALSE, TRUE, FALSE, FALSE,FALSE, FALSE, TRUE)) expect_identical(backports:::endsWith(t1, "n"), c(FALSE,FALSE, FALSE, FALSE,FALSE, TRUE, TRUE)) expect_identical(backports:::endsWith(t1, "an"), c(FALSE,FALSE, FALSE, FALSE,FALSE, FALSE, TRUE)) expect_identical(backports:::startsWith(t3, "M" ), c( TRUE, FALSE, TRUE)) expect_identical(backports:::startsWith(t3, "Ma"), c( TRUE, FALSE, FALSE)) expect_identical(backports:::startsWith(t3, "Mä"), c(FALSE, FALSE, TRUE)) backports/tests/test_URLencode.R0000644000176200001440000000064513636753630016427 0ustar liggesuserssource("helper/helper.R") f = get("URLencode", envir = getNamespace("utils")) z = "ab%20cd" expect_identical(backports:::URLencode(z, repeated = TRUE), "ab%2520cd") if (getRversion() >= "3.2.0") { expect_same = makeCompareFun(f, backports:::URLencode) expect_same(z) expect_same(z, repeated = FALSE) expect_same(z, repeated = TRUE) } else { expect_identical(f(z), backports:::URLencode(z, repeated = TRUE)) } backports/tests/test_stopifnot.R0000644000176200001440000000104314147211264016613 0ustar liggesuserssource("helper/helper.R") expect_silent = function(x) { ok = try(eval.parent(substitute(x)), silent = TRUE) if (inherits(ok, "try-error")) stop(deparse(substitute(x)), " threw an error") } f = backports:::stopifnot expect_error(f("Test" = 1 == 2), "Test") expect_silent(f("Test" = 1 == 1)) expect_error(f("Test 1" = 1 == 2, "Test 2" = 2 == 2), "Test 1") expect_error(f("Test 1" = 1 == 2, "Test 2" = 2 == 3), "Test 1") expect_error(f("Test 1" = 1 == 1, "Test 2" = 2 == 3), "Test 2") expect_silent(f("Test 1" = 1 == 1, "Test 2" = 2 == 2)) backports/tests/test_dir.exists.R0000644000176200001440000000043613636753630016701 0ustar liggesuserssource("helper/helper.R") if (exists("dir.exists", envir = baseenv())) { f = get("dir.exists", envir = baseenv()) expect_same = makeCompareFun(f, backports:::dir.exists) expect_same(tempdir()) expect_same(tempfile()) expect_same(rep.int(tempdir(), 2)) expect_same(TRUE) } backports/tests/test_dotsLength.R0000644000176200001440000000101613636753630016713 0ustar liggesuserssource("helper/helper.R") wb = function(...) backports:::...length() if (exists("...length", envir = baseenv())) { f = get("...length", envir = baseenv()) wf = function(...) f() expect_same = makeCompareFun(wf, wb) expect_same(1) expect_same(1, 2) expect_same() } expect_identical(wb(1, "a", "b", "c"), 4L) expect_identical(wb(2, "a", "b"), 3L) expect_identical(wb(1), 1L) expect_identical(wb(), 0L) f = function(n) backports:::...length() expect_error(f(), "current call") expect_error(f(1), "current call") backports/tests/test_list2DF.R0000644000176200001440000000056714147211264016047 0ustar liggesuserssource("helper/helper.R") if (exists("list2DF", envir = baseenv())) { f = get("list2DF", envir = baseenv()) expect_same = makeCompareFun(f, backports:::list2DF) x <- list(c("A", "B"), c("B", "C")) n <- lengths(x) expect_same(list(x = x, n = n)) ## Create data frames with no variables and the desired number of rows: expect_same() expect_same(nrow = 3L) } backports/src/0000755000176200001440000000000014155622472013041 5ustar liggesusersbackports/src/init.c0000644000176200001440000000105314147211264014141 0ustar liggesusers#include #include #include // for NULL #include /* .Call calls */ extern SEXP dotsElt(SEXP, SEXP); extern SEXP dotsLength(SEXP); extern SEXP dotsNames(SEXP); static const R_CallMethodDef CallEntries[] = { {"dotsElt", (DL_FUNC) &dotsElt, 2}, {"dotsLength", (DL_FUNC) &dotsLength, 1}, {"dotsNames", (DL_FUNC) &dotsNames, 1}, {NULL, NULL, 0} }; void R_init_backports(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); } backports/src/dotsElt.c0000644000176200001440000000077513636753630014640 0ustar liggesusers#include #include SEXP dotsElt(SEXP env_, SEXP i_) { SEXP ddd = findVar(R_DotsSymbol, env_); int i = INTEGER(i_)[0]; R_len_t n = length(ddd); if (ddd == R_UnboundValue) error("incorrect context: the current call has no '...' to look in"); if (i <= 0) error("indexing '...' with non-positive index %d", i); if (i > n) error("the ... list does not contain %d elements", i); ddd = nthcdr(ddd, i - 1); return eval(CAR(ddd), env_); } backports/src/dotsLength.c0000644000176200001440000000044313636753630015325 0ustar liggesusers#include #include SEXP dotsLength(SEXP env_) { SEXP ddd = findVar(R_DotsSymbol, env_); if (ddd == R_UnboundValue) error("incorrect context: the current call has no '...' to look in"); return ScalarInteger(TYPEOF(ddd) == DOTSXP ? length(ddd) : 0); } backports/src/dotsNames.c0000644000176200001440000000147014155621676015151 0ustar liggesusers#include #include #define length_DOTS(_v_) (TYPEOF(_v_) == DOTSXP ? length(_v_) : 0) SEXP dotsNames(SEXP env) { SEXP vl = findVar(R_DotsSymbol, env); PROTECT(vl); if (vl == R_UnboundValue) error("incorrect context: the current call has no '...' to look in"); // else SEXP out; int n = length_DOTS(vl); Rboolean named = FALSE; for(int i = 0; i < n; i++) { if(TAG(vl) != R_NilValue) { if(!named) { named = TRUE; PROTECT(out = allocVector(STRSXP, n)); // and is filled with "" already } SET_STRING_ELT(out, i, PRINTNAME(TAG(vl))); } vl = CDR(vl); } if(named) { UNPROTECT(1); } else { out = R_NilValue; } UNPROTECT(1); return out; } #undef length_DOTS backports/R/0000755000176200001440000000000014147211335012444 5ustar liggesusersbackports/R/file.mode.R0000644000176200001440000000024513636753627014453 0ustar liggesusers#' @rdname file.size #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(file.mode) file.mode = function(...) { base::file.info(...)$mode } backports/R/startsWith.R0000644000176200001440000000121513636753627014763 0ustar liggesusers#' @title Backport of startsWith for R < 3.3.0 #' @rdname startsWith #' #' @description #' See the original description in \code{base::startsWith}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.3.0") export(startsWith) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_startsWith = getFromNamespace("startsWith", "backports") #' #' bp_startsWith(c("aabb", "bbcc"), "bb") startsWith = function(x, prefix) { if (!is.character(x) || !is.character(prefix)) stop("non-character object(s)") suppressWarnings(substr(x, 1L, nchar(prefix)) == prefix) } backports/R/valid.factor.R0000644000176200001440000000132313636753627015163 0ustar liggesusers#' @title Backport of .valid.factor for R < 3.4.0 #' @rdname valid.factor #' #' @description #' See the original description in \code{base::.valid.factor}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.4.0") export(.valid.factor) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_.valid_factor = getFromNamespace(".valid.factor", "backports") #' bp_.valid_factor(factor(letters[1:3])) .valid.factor = function (object) { levs <- levels(object) if (!is.character(levs)) return("factor levels must be \"character\"") if (d <- anyDuplicated(levs)) return(sprintf("duplicated level [%d] in factor", d)) TRUE } backports/R/vignetteInfo.R0000644000176200001440000000073713672250205015240 0ustar liggesusers#' @title Backport of vignetteInfo for R < 3.6.0 #' #' @description #' See the original description in \code{tools::vignetteInfo}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(vignetteInfo) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_vignetteInfo = getFromNamespace("vignetteInfo", "backports") vignetteInfo <- getFromNamespace("vignetteInfo", ns = "tools") backports/R/zzz.R0000644000176200001440000000020713722007576013433 0ustar liggesusers#' @importFrom utils getFromNamespace head "_PACKAGE" .onUnload = function (libpath) { library.dynam.unload("backports", libpath) } backports/R/paste.R0000644000176200001440000000141514147211264013705 0ustar liggesusers#' @title Backport of paste for R < 4.0.1 #' @rdname paste #' #' @description #' See the original description in \code{base::paste}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.1") export(paste) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_paste = getFromNamespace("paste", "backports") #' bp_paste(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) paste <- function(..., sep = " ", collapse = NULL, recycle0 = FALSE) { if(recycle0 && any(lengths(list(...)) == 0L)) { base::paste(sep = sep, collapse = collapse) # for argument checking if (is.null(collapse)) character() else "" } else { base::paste(..., sep = sep, collapse = collapse) } } backports/R/URLencode.R0000644000176200001440000000207413636753627014433 0ustar liggesusers#' @title Backport of URLencode for R < 3.2.0 #' @rdname URLencode #' #' @description #' See the original description in \code{utils::URLencode}. #' Argument \code{repeated} is backported. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(URLencode) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_URLencode = getFromNamespace("URLencode", "backports") #' #' URLdecode(z <- "ab%20cd") #' c(bp_URLencode(z), bp_URLencode(z, repeated = TRUE)) URLencode = function(URL, reserved = FALSE, repeated = FALSE) { if (!repeated && grepl("%[[:xdigit:]]{2}", URL, useBytes = TRUE)) return(URL) OK <- paste0( "[^", if (!reserved) "][!$&'()*+,;=:/?@#", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz0123456789._~-", "]" ) x <- strsplit(URL, "")[[1L]] z <- grep(OK, x) if (length(z)) { y <- sapply(x[z], function(x) paste0("%", toupper(as.character(charToRaw(x))), collapse = "")) x[z] <- y } paste(x, collapse = "") } backports/R/isFALSE.R0000644000176200001440000000102513636753627013774 0ustar liggesusers#' @title Backport of isFALSE for R < 3.4.2 #' @rdname isFALSE #' #' @description #' See the original description in \code{base::isFALSE}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.5.0") export(isFALSE) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_isFALSE = getFromNamespace("isFALSE", "backports") #' #' bp_isFALSE(FALSE) #' bp_isFALSE(iris) isFALSE = function(x) { is.logical(x) && length(x) == 1L && !is.na(x) && !x } backports/R/trimws.R0000644000176200001440000000145113636753627014136 0ustar liggesusers#' @title Backport of trimws for R < 3.3.0 #' @rdname trimws #' #' @description #' See the original description in \code{base::trimws}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(trimws) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_trimws = getFromNamespace("trimws", "backports") #' bp_trimws(c(" a ", "b ", " c")) #' #' bp_trimws(c(" a ", "b ", " c"), which = "left") trimws = function(x, which = c("both", "left", "right")) { which = match.arg(which) mysub = function(re, x) sub(re, "", x, perl = TRUE) if (which == "left") return(mysub("^[ \t\r\n]+", x)) if (which == "right") return(mysub("[ \t\r\n]+$", x)) mysub("[ \t\r\n]+$", mysub("^[ \t\r\n]+", x)) } backports/R/get0.R0000644000176200001440000000200014005747225013423 0ustar liggesusers#' @title Backport of get0 for R < 3.2.0 #' @rdname get0 #' #' @description #' See the original description in \code{base::get0}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(get0) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_get0 = getFromNamespace("get0", "backports") #' #' bp_get0("a") #' bp_get0("a", ifnotfound = 0) #' #' foo = 12 #' bp_get0("foo") get0 = function(x, envir = pos.to.env(-1L), mode = "any", inherits = TRUE, ifnotfound = NULL) { if (!is.character(x) || length(x) == 0L) { stop("Invalid first argument") } if (length(x) > 1L && getRversion() >= "4.1.0") { # this check was introduced in R-4.1.0 # We can remove the version check as soon as all CRAN packages have been updated, # i.e. as soon as 4.1.0 is released stop("first argument has length > 1") } mget(x[1L], envir = envir, mode = mode, inherits = inherits, ifnotfound = list(ifnotfound))[[1L]] } backports/R/removeSource.R0000644000176200001440000000222314005747225015251 0ustar liggesusers#' @title Backport of removeSource for R < 3.6.0 #' @rdname removeSource #' #' @description #' See the original description in \code{utils::removeSource}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(removeSource) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_removeSource = getFromNamespace("removeSource", "backports") #' #' bp_removeSource(mean) removeSource = function (fn) { recurse <- function(part) { if (is.name(part)) return(part) attr(part, "srcref") <- NULL attr(part, "wholeSrcref") <- NULL attr(part, "srcfile") <- NULL if (is.language(part) && is.recursive(part)) { for (i in seq_along(part)) part[i] <- list(recurse(part[[i]])) } part } if (is.function(fn)) { if (!is.primitive(fn)) { attr(fn, "srcref") <- NULL attr(body(fn), "wholeSrcref") <- NULL attr(body(fn), "srcfile") <- NULL body(fn) <- recurse(body(fn)) } fn } else if (is.language(fn)) { recurse(fn) } else { stop("argument is not a function or language object:", typeof(fn)) } } backports/R/R_user_dir.R0000644000176200001440000000402213642106266014667 0ustar liggesusers#' @title Backport of R_user_dir for R < 4.0.0 #' #' @description #' See the original description in \code{tools::R_user_dir}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.0") export(R_user_dir) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_R_user_dir = getFromNamespace("R_user_dir", "backports") #' #' bp_R_user_dir("backports") R_user_dir <- function(package, which = c("data", "config", "cache")) { stopifnot(is.character(package), length(package) == 1L) which <- match.arg(which) home <- normalizePath("~") path <- switch(which, data = { if(nzchar(p <- Sys.getenv("R_USER_DATA_DIR"))) p else if(nzchar(p <- Sys.getenv("XDG_DATA_HOME"))) p else if(.Platform$OS.type == "windows") file.path(Sys.getenv("APPDATA"), "R", "data") else if(Sys.info()["sysname"] == "Darwin") file.path(home, "Library", "Application Support", "org.R-project.R") else file.path(home, ".local", "share") }, config = { if(nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR"))) p else if(nzchar(p <- Sys.getenv("XDG_CONFIG_HOME"))) p else if(.Platform$OS.type == "windows") file.path(Sys.getenv("APPDATA"), "R", "config") else if(Sys.info()["sysname"] == "Darwin") file.path(home, "Library", "Preferences", "org.R-project.R") else file.path(home, ".config") }, cache = { if(nzchar(p <- Sys.getenv("R_USER_CACHE_DIR"))) p else if(nzchar(p <- Sys.getenv("XDG_CACHE_HOME"))) p else if(.Platform$OS.type == "windows") file.path(Sys.getenv("LOCALAPPDATA"), "R", "cache") else if(Sys.info()["sysname"] == "Darwin") file.path(home, "Library", "Caches", "org.R-project.R") else file.path(home, ".cache") }) file.path(path, "R", package) } backports/R/dotsLength.R0000644000176200001440000000110113636753627014714 0ustar liggesusers#' @title Backport of ...length for R < 3.4.2 #' @rdname dotsLength #' #' @description #' See the original description in \code{base::...length}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.5.0") export(...length) #' @useDynLib backports dotsLength #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_...length = getFromNamespace("...length", "backports") #' #' foo = function(...) bp_...length() #' foo(1, 2, 3) ...length = function() { .Call(dotsLength, parent.frame()) } backports/R/strrep.R0000644000176200001440000000141013636753627014123 0ustar liggesusers#' @title Backport of strrep for R < 3.3.0 #' @rdname strrep #' #' @description #' See the original description in \code{base::strrep}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.3.0") export(strrep) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_strrep = getFromNamespace("strrep", "backports") #' #' bp_strrep("-", 10) strrep = function(x, times) { x = as.character(x) if (length(x) == 0L) return(x) unlist(.mapply(function(x, times) { if (is.na(x) || is.na(times)) return(NA_character_) if (times <= 0L) return("") paste0(replicate(times, x), collapse = "") }, list(x = x, times = times), MoreArgs = list()), use.names = FALSE) } backports/R/isTRUE.R0000644000176200001440000000130213636753627013717 0ustar liggesusers#' @title Backport of isTRUE for R < 3.5.0 #' @rdname isTRUE #' #' @description #' The implementation of `isTRUE` has been changed in R-3.5.0 from #' \code{identical(x, TRUE)} to \code{is.logical(x) && length(x) == 1L && !is.na(x) && x}. #' This backport overloads the old implementation for R versions prior to 3.5.0. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.5.0") export(isTRUE) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_isTRUE = getFromNamespace("isTRUE", "backports") #' #' bp_isTRUE(FALSE) #' bp_isTRUE(iris) isTRUE = function(x) { is.logical(x) && length(x) == 1L && !is.na(x) && x } backports/R/isNamespaceLoaded.R0000644000176200001440000000110314005747225016130 0ustar liggesusers#' @title Backport of isNamespaceLoaded for R < 3.2.0 #' @rdname isNamespaceLoaded #' #' @description #' See the original description in \code{base::isNamespaceLoaded}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(isNamespaceLoaded) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_isNamespaceLoaded = getFromNamespace("isNamespaceLoaded", "backports") #' #' bp_isNamespaceLoaded("backports") isNamespaceLoaded = function(name) { name %in% loadedNamespaces() } backports/R/endsWith.R0000644000176200001440000000122413636753627014374 0ustar liggesusers#' @title Backport of endsWith for R < 3.3.0 #' @rdname endsWith #' #' @description #' See the original description in \code{base::endsWith}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.3.0") export(endsWith) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_endsWith = getFromNamespace("endsWith", "backports") #' #' bp_endsWith(c("aabb", "bbcc"), "bb") endsWith = function(x, suffix) { if (!is.character(x) || !is.character(suffix)) stop("non-character object(s)") n = nchar(x) suppressWarnings(substr(x, n - nchar(suffix) + 1L, n) == suffix) } backports/R/file.mtime.R0000644000176200001440000000025013636753627014636 0ustar liggesusers#' @rdname file.size #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(file.mtime) file.mtime = function(...) { base::file.info(...)$mtime } backports/R/file.info.R0000644000176200001440000000125313636753627014462 0ustar liggesusers#' @title Backport of \code{file.info} for R < 3.2.0 #' #' @description #' Argument \code{extra_cols} has been backported. #' See the original description in \code{base::file.info}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(file.info) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_file.info = getFromNamespace("file.info", "backports") #' #' bp_file.info(file.path(R.home(), "COPYING"), extra_cols = FALSE) file.info = function (..., extra_cols = TRUE) { if (isTRUE(extra_cols)) base::file.info(...) else base::file.info(...)[, 1:6, drop = FALSE] } backports/R/list2DF.R0000644000176200001440000000226414147211264014043 0ustar liggesusers#' @title Backport of list2DF for R < 4.0.0 #' @rdname list2DF #' #' @description #' See the original description in \code{base::list2DF}. #' Note that the behaviour of \code{list2DF()} changed in #' R 4.2.0. Instead of recycling vectors to common length, an #' exception is raised. #' This backport implements the new behaviour, #' throwing an error message. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.0") export(list2DF) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_list2DF = getFromNamespace("list2DF", "backports") #' #' bp_list2DF(list(x = 1:3, y = 2:4)) list2DF <- function(x = list(), nrow = 0L) { stopifnot(is.list(x), is.null(nrow) || nrow >= 0L) if (n <- length(x)) { if (length(nrow <- unique(lengths(x))) > 1L) stop("all variables should have the same length") } else { if (is.null(nrow)) nrow <- 0L } if (is.null(names(x))) names(x) <- character(n) class(x) <- "data.frame" attr(x, "row.names") <- .set_row_names(nrow) x } .set_row_names = function (n) if (n > 0) c(NA_integer_, -n) else integer() backports/R/file.size.R0000644000176200001440000000133213636753627014477 0ustar liggesusers#' @title Backports of wrappers around \code{file.info} for R < 3.2.0 #' @rdname file.size #' #' @description #' See the original description in \code{base::file.size}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(file.size) #' @examples #' # get functions from namespace instead of possibly getting #' # implementations shipped with recent R versions: #' bp_file.size = getFromNamespace("file.size", "backports") #' bp_file.mode = getFromNamespace("file.size", "backports") #' bp_file.mtime = getFromNamespace("file.size", "backports") #' #' fn = file.path(R.home(), "COPYING") #' bp_file.size(fn) #' bp_file.mode(fn) #' bp_file.size(fn) file.size = function(...) { base::file.info(...)$size } backports/R/dotsNames.R0000644000176200001440000000107714147211264014532 0ustar liggesusers#' @title Backport of ...names for R < 4.1.0 #' @rdname dotsNames #' #' @description #' See the original description in \code{base::...names}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.1.0") export(...names) #' @useDynLib backports dotsNames #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_...names = getFromNamespace("...names", "backports") #' #' foo = function(...) bp_...names() #' foo(a = 1, b = 2, 3) ...names = function() { .Call(dotsNames, parent.frame()) } backports/R/hasName.R0000644000176200001440000000103413636753627014162 0ustar liggesusers#' @title Backport of hasName for R < 3.4.0 #' @rdname hasName #' #' @description #' See the original description in \code{utils::hasName}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.4.0") export(hasName) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_hasName = getFromNamespace("hasName", "backports") #' #' bp_hasName(list(a = 1, b = 2), c("a", "b", "c")) hasName = function(x, name) { match(name, names(x), nomatch = 0L) > 0L } backports/R/lengths.R0000644000176200001440000000105013657037646014247 0ustar liggesusers#' @title Backport of lengths for R < 3.2.0 #' @rdname lengths #' #' @description #' See the original description in \code{base::lengths}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(lengths) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_lengths = getFromNamespace("lengths", "backports") #' #' bp_lengths(list(1:3, 2)) lengths = function(x, use.names = TRUE) { vapply(x, length, FUN.VALUE = NA_integer_, USE.NAMES = use.names) } backports/R/stopifnot.R0000644000176200001440000000526214147211264014622 0ustar liggesusers#' @title Backport of stopifnot for R versions < 4.0.0. #' #' @description #' See the original description in \code{base::stopifnot}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.0") export(stopifnot) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_stopifnot = getFromNamespace("stopifnot", "backports") #' #' m <- matrix(c(1, 3, 12, 1), 2, 2) #' \dontrun{bp_stopifnot("m must be symmetric" = m == t(m))} stopifnot = function(..., exprs, exprObject, local = TRUE) { n <- ...length() if ((has.e <- !missing(exprs)) || !missing(exprObject)) { if (n || (has.e && !missing(exprObject))) stop("Only one of 'exprs', 'exprObject' or expressions, not more") envir <- if (isTRUE(local)) parent.frame() else if (isFALSE(local)) .GlobalEnv else if (is.environment(local)) local else stop("'local' must be TRUE, FALSE or an environment") E1 <- if (has.e && is.call(exprs <- substitute(exprs))) exprs[[1]] cl <- if (is.symbol(E1) && E1 == quote(`{`)) { exprs[[1]] <- quote(stopifnot) ## --> stopifnot(*, *, ..., *) : exprs } else as.call(c(quote(stopifnot), if (!has.e) exprObject else as.expression(exprs))) # or fail .. names(cl) <- NULL return(eval(cl, envir = envir)) } ## else use '...' (and not 'exprs') : Dparse <- function(call, cutoff = 60L) { ch <- deparse(call, width.cutoff = cutoff) if (length(ch) > 1L) paste(ch[1L], "....") else ch } head <- function(x, n = 6L) ## basically utils:::head.default() x[seq_len(if (n < 0L) max(length(x) + n, 0L) else min(n, length(x)))] abbrev <- function(ae, n = 3L) paste(c(head(ae, n), if (length(ae) > n) "...."), collapse = "\n ") ## for (i in seq_len(n)) { r <- ...elt(i) if (!(is.logical(r) && !anyNA(r) && all(r))) { dots <- match.call()[-1L] if (is.null(msg <- names(dots)) || !nzchar(msg <- msg[i])) { cl.i <- dots[[i]] msg <- ## special case for decently written 'all.equal(*)': if (is.call(cl.i) && identical(cl.i[[1]], quote(all.equal)) && (is.null(ni <- names(cl.i)) || length(cl.i) == 3L || length(cl.i <- cl.i[!nzchar(ni)]) == 3L)) sprintf(gettext("%s and %s are not equal:\n %s"), Dparse(cl.i[[2]]), Dparse(cl.i[[3]]), abbrev(r)) else sprintf(ngettext(length(r), "%s is not TRUE", "%s are not all TRUE"), Dparse(cl.i)) } stop(simpleError(msg, call = if (p <- sys.parent(1L)) sys.call(p))) } } invisible() } backports/R/warningCondition.R0000644000176200001440000000174013636753627016126 0ustar liggesusers#' @title Backport of warningCondition and errorCondition for R < 3.6.0 #' @rdname warningCondition #' #' @description #' See the original description in \code{base::warningCondition}/\code{base::errorCondition}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(warningCondition) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_warningCondition = getFromNamespace("warningCondition", "backports") #' bp_warningCondition("package backports not found") warningCondition <- function(msg, ..., class = NULL, call = NULL) { structure(list(message = msg, call = call, ...), class = c(class, "warning", "condition")) } #' @rdname warningCondition #' @rawNamespace if (getRversion() < "3.6.0") export(errorCondition) errorCondition <- function(msg, ..., class = NULL, call = NULL) { structure(list(message = msg, call = call, ...), class = c(class, "error", "condition")) } backports/R/anyNA.R0000644000176200001440000000113113636753627013612 0ustar liggesusers#' @title Backport of anyNA for R versions < 3.2.0. #' #' @description #' See the original description in \code{base::anyNA}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(anyNA) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_anyNA = getFromNamespace("anyNA", "backports") #' #' bp_anyNA(letters) anyNA = function(x, recursive = FALSE) { if (isTRUE(recursive) && (is.list(x) || is.pairlist(x))) return(any(rapply(x, anyNA, how = "unlist", recursive = FALSE))) any(is.na(x)) } backports/R/deparse1.R0000644000176200001440000000111313657041607014277 0ustar liggesusers#' @title Backport of deparse1 for R < 4.0.0 #' @rdname deparse1 #' #' @description #' See the original description in \code{base::deparse1}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.0") export(deparse1) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_deparse1 = getFromNamespace("deparse1", "backports") #' #' bp_deparse1(quote(`foo bar`)) deparse1 = function (expr, collapse = " ", width.cutoff = 500L, ...) { paste(deparse(expr, width.cutoff, ...), collapse = collapse) } backports/R/str2lang.R0000644000176200001440000000111413722007576014330 0ustar liggesusers#' @title Backport of str2lang for R < 3.6.0 #' @rdname str2lang #' #' @description #' See the original description in \code{base::str2lang}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(str2lang) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' str2lang <- getFromNamespace("str2lang", "backports") #' #' str2lang("x[3] <- 1+4") str2lang <- function(s) { stopifnot(length(s) == 1L) ex <- parse(text=s, keep.source=FALSE) stopifnot(length(ex) == 1L) ex[[1L]] } backports/R/import.R0000644000176200001440000000524314147211335014105 0ustar liggesusers#' @title Import backported functions into your package #' #' @description #' Imports objects from \pkg{backports} into the namespace of other packages #' by assigning it during load-time. #' See examples for a code snippet to copy to your package. #' #' @param pkgname [\code{character(1)}]\cr #' Name of the package where the backported function should be assigned. #' @param obj [\code{character}]\cr #' Name of objects to assign, as character vector. #' If \code{NULL}, all backports which are not provided by R itself are assigned. #' @param force [\code{logical}]\cr #' If \code{obj} is provided and \code{force} is set to \code{FALSE}, only backports #' not provided by the base package of the executing R interpreter are imported. #' Set to \code{TRUE} to ignore this check and always import the backport into the package's namespace. #' @export #' @seealso \code{\link{.onLoad}} #' @examples #' \dontrun{ #' # This imports all functions implemented in backports while the package is loaded #' .onLoad <- function(libname, pkgname) { #' backports::import(pkgname) #' } #' #' # This only imports the function "trimws" #' .onLoad <- function(libname, pkgname) { #' backports::import(pkgname, "trimws") #' } #' #' # This imports all backports from base and force-imports "hasName" from utils #' .onLoad <- function(libname, pkgname) { #' backports::import(pkgname) #' backports::import(pkgname, "hasName", force = TRUE) #' } #' } import = function(pkgname, obj = NULL, force = FALSE) { if (is.null(obj)) { obj = get_backports() } else if (!isTRUE(force)) { obj = intersect(obj, get_backports()) } if (length(obj) > 0L) { pkg = getNamespace(pkgname) backports = getNamespace("backports") for (x in obj) { assign(x, get(x, envir = backports), envir = pkg) } } invisible(TRUE) } get_backports = function(v = getRversion()) { v = package_version(v) nn = names(FUNS) for (i in seq_along(FUNS)) { if (v >= nn[i]) break } unlist(head(FUNS, i - 1L), use.names = FALSE) } FUNS = list( "4.1.0" = c("...names"), "4.0.1" = c("paste", "paste0"), "4.0.0" = c("R_user_dir", "deparse1", "list2DF", "suppressWarnings", "suppressMessages", "stopifnot"), "3.6.0" = c("warningCondition", "errorCondition", "vignetteInfo", "dQuote", "sQuote", "removeSource", "asplit"), "3.5.0" = c("...length", "...elt", "isFALSE", "isTRUE"), "3.4.0" = c("hasName"), "3.3.0" = c("startsWith", "endsWith", "strrep", "trimws", "capture.output"), "3.2.0" = c("anyNA", "dir.exists", "file.size", "file.mode", "file.mtime", "lengths", "file.info", "URLencode", "isNamespaceLoaded"), "3.1.0" = character(), "3.0.0" = character(), "0.0.0" = character() ) backports/R/asplit.R0000644000176200001440000000255514005747225014077 0ustar liggesusers#' @title Backport of asplit for R < 3.6.0 #' @rdname asplit #' #' @description #' See the original description in \code{base::asplit}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(asplit) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_asplit = getFromNamespace("asplit", "backports") #' x = matrix(1:6, 2, 3) #' bp_asplit(x, 1) asplit = function (x, MARGIN) { dl <- length(dim(x)) if (!dl) stop("dim(x) must have a positive length") if (is.object(x)) x <- if (dl == 2L) as.matrix(x) else as.array(x) d <- dim(x) dn <- dimnames(x) ds <- seq_len(dl) if (is.character(MARGIN)) { if (is.null(dnn <- names(dn))) stop("'x' must have named dimnames") MARGIN <- match(MARGIN, dnn) if (anyNA(MARGIN)) stop("not all elements of 'MARGIN' are names of dimensions") } s.call <- ds[-MARGIN] s.ans <- ds[MARGIN] d.call <- d[-MARGIN] d.ans <- d[MARGIN] dn.call <- dn[-MARGIN] dn.ans <- dn[MARGIN] d2 <- prod(d.ans) newx <- aperm(x, c(s.call, s.ans)) dim(newx) <- c(prod(d.call), d2) ans <- vector("list", d2) for (i in seq_len(d2)) { ans[[i]] <- array(newx[, i], d.call, dn.call) } array(ans, d.ans, dn.ans) } backports/R/dotsElt.R0000644000176200001440000000110413636753627014222 0ustar liggesusers#' @title Backport of ...elt for R < 3.4.2 #' @rdname dotsElt #' #' @description #' See the original description in \code{base::...elt}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.5.0") export(...elt) #' @useDynLib backports dotsElt #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_...elt = getFromNamespace("...elt", "backports") #' #' foo = function(n, ...) bp_...elt(n) #' foo(n = 2, "a", "b", "c") ...elt = function(n) { .Call(dotsElt, parent.frame(), as.integer(n)) } backports/R/dQuote.R0000644000176200001440000000473313642106266014044 0ustar liggesusers#' @title Backport of dQuote and sQuote for R < 3.6.0 #' #' @description #' Argument \code{q} has been backported. #' See the original description in \code{base::dQuote()} and \code{base::sQuote()}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(dQuote) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_dQuote <- getFromNamespace("dQuote", "backports") #' bp_dQuote("foo") #' bp_dQuote("foo", q = TRUE) dQuote <- function(x, q = getOption("useFancyQuotes")) { if (!length(x)) return(character()) before <- after <- "\"" if(!is.null(q)) { if(isTRUE(q)) { li <- l10n_info() if(li$"UTF-8") q <- "UTF-8" if(!is.null(li$codepage) && li$codepage > 0L) { if(li$codepage >= 1250L && li$codepage <= 1258L || li$codepage == 874L) { before <- rawToChar(as.raw(0x93)) after <- rawToChar(as.raw(0x94)) } else { z <- iconv(c(intToUtf8(0x201c), intToUtf8(0x201d)), "UTF-8", "") before <- z[1L]; after <- z[2L] } } } if(identical(q, "TeX")) { before <- "``"; after <- "''" } if(identical(q, "UTF-8")) { before <- intToUtf8(0x201c); after <- intToUtf8(0x201d) } if(is.character(q) && length(q) >= 4L) { before <- q[3L]; after <- q[4L] } } paste0(before, x, after) } #' @rdname dQuote #' @rawNamespace if (getRversion() < "3.6.0") export(sQuote) sQuote <- function(x, q = getOption("useFancyQuotes")) { if (!length(x)) return(character()) before <- after <- "'" if(!is.null(q)) { if(isTRUE(q)) { li <- l10n_info() if(li$"UTF-8") q <- "UTF-8" if(!is.null(li$codepage) && li$codepage > 0L) { ## we can't just use iconv, as that seems to think ## it is in latin1 in CP1252 if(li$codepage >= 1250L && li$codepage <= 1258L || li$codepage == 874L) { before <- rawToChar(as.raw(0x91)) after <- rawToChar(as.raw(0x92)) } else { z <- iconv(c(intToUtf8(0x2018), intToUtf8(0x2019)), "UTF-8", "") before <- z[1L]; after <- z[2L] } } } if(identical(q, "TeX")) { before <- "`"; after <- "'" } if(identical(q, "UTF-8")) { before <- intToUtf8(0x2018); after <- intToUtf8(0x2019) } if(is.character(q) && length(q) >= 4L) { before <- q[1L]; after <- q[2L] } } paste0(before, x, after) } backports/R/str2expression.R0000644000176200001440000000105213722007576015607 0ustar liggesusers#' @title Backport of str2expression for R < 3.6.0 #' @rdname str2expression #' #' @description #' See the original description in \code{base::str2expression}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.6.0") export(str2expression) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' str2expression <- getFromNamespace("str2expression", "backports") #' #' str2expression("x[3] <- 1+4") str2expression <- function(text) parse(text=text, keep.source=FALSE) backports/R/capture.output.R0000644000176200001440000000346713642106266015610 0ustar liggesusers#' @title Backport of capture.output for R < 3.3.0 #' #' @description #' Argument \code{type} has been backported. #' See the original description in \code{utils::capture.output}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.3.0") export(capture.output) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_capture.output <- getFromNamespace("capture.output", "backports") #' #' captured <- bp_capture.output({ message("hi") }, type = "message") #' str(captured) capture.output <- function(..., file=NULL, append=FALSE, type = c("output", "message"), split = FALSE) { args <- substitute(list(...))[-1L] type <- match.arg(type) rval <- NULL; closeit <- TRUE if (is.null(file)) file <- textConnection("rval", "w", local = TRUE) else if (is.character(file)) file <- file(file, if(append) "a" else "w") else if (inherits(file, "connection")) { if (!isOpen(file)) open(file, if(append) "a" else "w") else closeit <- FALSE } else { stop("'file' must be NULL, a character string or a connection") } sink(file, type=type, split=split) ## for error recovery: all output will be lost if file=NULL on.exit({sink(type=type, split=split); if(closeit) close(file)}) pf <- parent.frame() evalVis <- function(expr) withVisible(eval(expr, pf)) for(i in seq_along(args)) { expr <- args[[i]] tmp <- switch(mode(expr), "expression" = lapply(expr, evalVis), "call" =, "name" = list(evalVis(expr)), stop("bad argument") ) for(item in tmp) if (item$visible) print(item$value) } ## we need to close the text connection before returning 'rval' on.exit() sink(type=type, split=split) if(closeit) close(file) if(is.null(rval)) invisible(NULL) else rval } backports/R/paste0.R0000644000176200001440000000113514147211264013764 0ustar liggesusers#' @title Backport of paste0 for R < 4.0.1 #' @rdname paste0 #' #' @description #' See the original description in \code{base::paste0}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.1") export(paste0) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_paste0 = getFromNamespace("paste0", "backports") #' bp_paste0(letters[1:3], character(), collapse = NULL, recycle0 = TRUE) paste0 <- function(..., collapse = NULL, recycle0 = FALSE) { paste(..., sep = "", collapse = collapse, recycle0 = recycle0) } backports/R/suppressWarnings.R0000644000176200001440000000236313730224071016166 0ustar liggesusers#' @title Backport of suppressWarnings and suppressMessages for R < 4.0.0 #' @rdname suppressWarnings #' #' @description #' Backport for new argument `classes`. #' See the original description in \code{base::suppressWarnings}/\code{base::suppressMessages}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.0.0") export(suppressWarnings) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_suppressWarnings = getFromNamespace("suppressWarnings", "backports") #' bp_suppressWarnings(warningCondition("warning", class = "testWarning"), "testWarning") suppressWarnings = function (expr, classes = "warning") { withCallingHandlers(expr, warning = function(w) if (inherits(w, classes)) tryInvokeRestart("muffleWarning") ) } #' @rdname suppressWarnings #' @rawNamespace if (getRversion() < "4.0.0") export(suppressMessages) suppressMessages = function (expr, classes = "message") { withCallingHandlers(expr, message = function(c) if (inherits(c, classes)) tryInvokeRestart("muffleMessage") ) } tryInvokeRestart = function (r, ...) { if (!isRestart(r)) r <- findRestart(r) if (is.null(r)) invisible(NULL) else invokeRestart(r, ...) } backports/R/dir.exists.R0000644000176200001440000000101013636753627014674 0ustar liggesusers#' @title Backport of dir.exists for R < 3.2.0 #' #' @description #' See the original description in \code{base::dir.exists}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "3.2.0") export(dir.exists) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_dir.exists = getFromNamespace("dir.exists", "backports") #' #' bp_dir.exists(tempdir()) dir.exists = function(paths) { x = base::file.info(paths)$isdir !is.na(x) & x } backports/NEWS.md0000644000176200001440000000650714155622143013353 0ustar liggesusers# backports 1.4.1 * Patched `...names()` to match the new implementation in r-devel (svn rev 81283). # backports 1.4.0 * Added `paste()` with support for argument `recycle0` for R versions prior to 4.0.1. * Added `paste0()` with support for argument `recycle0` for R versions prior to 4.0.1. * Added backport for `...names()` for R versions prior to 4.1.0. # backports 1.3.0 * Added backport for `stopifnot()` for R versions prior to 4.0.0. * Adapted `list2DF()` to new behaviour introduced in r81038: the inputs are not recycled anymore to common length. Instead, an error is thrown. # backports 1.2.1 * Adapted `get0()` to work with R-devel / R-4.1.0 for first argument having length greater than 1. # backports 1.2.0 * Switched to semantic versioning. * Added backport for `asplit()` for R versions prior to 3.6.0 (#47). * Added backport for `removeSource()` which also supports language objects for R versions prior to 3.6.0 (#50). * Added backport for `isNamespaceLoaded` for R versions prior to 3.2.0 (#49). # backports 1.1.10 * Added `suppressMessages()` and `suppressWarnings()` with support for argument `classes` for R versions prior to 4.0.0 # backports 1.1.9 * Added backports for `str2lang()` and `str2expression()` (#42) Thanks to @dmurdoch. * `import()` imported too many functions and has been fixed. # backports 1.1.8 * Added backport for `tools::vignetteInfo()` for R versions prior to 3.6.0 * Fixed import of `list2DF()` and `deparse1()` # backports 1.1.7 * Added backport for `deparse1()` for R versions prior to 4.0.0. * Added backport for `list2DF()` for R versions prior to 4.0.0. # backports 1.1.6 * Added backport for `R_user_dir()` for R versions prior to 4.0.0. * Added `dQuote()` and `sQuote()` with support for argument `q` for R versions prior to 3.6.0. # backports 1.1.5 * Changed license from GPL-2 to GPL-2 or GPL-3. * Added backport for `isTRUE()` implementing the new behaviour introduced in R 3.5.0. # backports 1.1.4 * Fixed import of `warningCondition()` and `errorCondition()`. # backports 1.1.3 * Added `warningCondition()` and `errorCondition()` for R versions prior to 3.6.0. * Added `capture.output()` with support for argument `type` for R versions prior to 3.3.0. * Added `URLencode()` with support for argument `repeated` for R versions prior to 3.2.0. # backports 1.1.2 * Improved import mechanism. * Added `.valid.factor()` for R versions prior to 3.4.0. # backports 1.1.1 * Added `...length()` and `...elt()` for R versions prior to 3.5.0. * Added `isFALSE()` for R versions prior to 3.5.0. # backports 1.1.0 * New import mechanism to import packages during load-time with the function `import()`. This is now the recommended way to use backports non-interactively. Simply importing backports in the NAMESPACE still works, but is comparably error-prone if the same library is used by multiple R installations. # backports 1.0.5 * Added `get0()` for R versions prior to 3.2.0. * Added examples. # backports 1.0.4 * Added `hasName()` for R versions prior to 3.4.0. * Added `file.info()` with backport for argument `extra_cols`. # backports 1.0.3 * Removed stringi dependency. # backports 1.0.2 * Fixed `file.size()`, `file.mtime()` and `file.mode()` for R-3.1.x. # backports 1.0.1 * Added `file.size()`, `file.mtime()` and `file.mode()` for R versions prior to 3.2.0. # backports 1.0.0 * Initial version. backports/MD50000644000176200001440000001352114155627272012567 0ustar liggesusersdcae325a172db42f3c1e099a01322639 *DESCRIPTION 4f4794836a94e4ff595414fdee688666 *NAMESPACE 679db662c4ea866704a5df27318ecc7b *NEWS.md 35c58f655ad5194e8af81d851c58e719 *R/R_user_dir.R 6dee293e8cc80c13e777ee75195e03dc *R/URLencode.R 41879b295859b9f3dd0efc69737d4a12 *R/anyNA.R 9c183e8ddeee8fd103b5910ebabab872 *R/asplit.R 24d8b9d2ebd6ad91d6b37527e4944e51 *R/capture.output.R dc36b33860d9fa47b76725c5c1793f31 *R/dQuote.R 8ed21dc3461c82e76ecaa51ea5bbba0b *R/deparse1.R e1fb60c17ea8a6677c3a80637f88c830 *R/dir.exists.R da64e21c278b5017993dcc2321552c8f *R/dotsElt.R 481b7311ab8961c4fef48b8ec6cd5eb0 *R/dotsLength.R 0fb613fa78490cd6f5ff7a88f1656763 *R/dotsNames.R 8d6708837ab0c9222d582576160dcdeb *R/endsWith.R daf73a06568906502efabcfa63cc3f45 *R/file.info.R f03ad94562dfb233f213366ceb192900 *R/file.mode.R 9733ea86cf7e4e2ad39c226b68ab73ff *R/file.mtime.R fd795349608133c5b9b4850c8bce7115 *R/file.size.R a9a4fe845be20018fb88d4d57237eb01 *R/get0.R b8bd9db45b49fe62e5101de2d80ac4ef *R/hasName.R c327e1df459466dae1b1601bdf18bc92 *R/import.R 71f82c7d4d76ea1bcf50c4882f2922a0 *R/isFALSE.R b6a23c8fa8e7b95266a59a8a9e9df3aa *R/isNamespaceLoaded.R 72a820a36c75b726315cdfb20fd025ac *R/isTRUE.R ee095da4109d7e289d11248e13ac9428 *R/lengths.R 9fa4f27a194d3742a1089db9a0dbfb71 *R/list2DF.R d2e6f4defdc9042a1dcf187b57634ed1 *R/paste.R 927ac9909aaa1f226a4381c43770d1c5 *R/paste0.R 785727dc006a54f96c6b69acce6fceca *R/removeSource.R 1d59834fa8a4c2572b8a047376837618 *R/startsWith.R cc35f9f3031992d3d50471b07e53ca67 *R/stopifnot.R 822ae9549b2c556551e07866f370e75e *R/str2expression.R 793e0383a107d5dad46e394a28be1711 *R/str2lang.R a4f40e3e2747b16bfe0cc6e80766e0f7 *R/strrep.R 7eb5cd5c0ffcd8069fbca150f1fb366b *R/suppressWarnings.R 2281b9271b328f1ce44735f433c57a1b *R/trimws.R f0a491f2249c61d129127d5277b428db *R/valid.factor.R b08798c5a61f613c60c595fbe01978a1 *R/vignetteInfo.R fdad95605776f3d0a6dca00edacc3d50 *R/warningCondition.R 30b29459fbd40ac5d14ab4491861773c *R/zzz.R e64c816546599b4ee2382e082192310c *README.md e668b5dd4f52ce96df2cf5e26d976eac *man/R_user_dir.Rd 9502c207e8163009cd99aaacefd6f544 *man/URLencode.Rd 5c3ef8d8d05cd9f2b6d63210b5924faa *man/anyNA.Rd ea27c68a89fb392dbd5a2cdf6e301c84 *man/asplit.Rd 8813284539bd905020b347c4a549babe *man/backports-package.Rd 7a57f80bd4560bd34f86c3ecc6c06a07 *man/capture.output.Rd 37f9ce75db00bf0f39ba0472ee971695 *man/dQuote.Rd ee249685c9b3c6f4abbeab6f8810dfb6 *man/deparse1.Rd a96f841e5bb26d875daafdec0ca3a12e *man/dir.exists.Rd 4b811bda283420d6bda01b250112119b *man/dotsElt.Rd 54f762138570780eaacbd437e19c6ff4 *man/dotsLength.Rd 701cd339f2e8e5162f59e2296e01f59c *man/dotsNames.Rd fff4aab715b29f9a293e46eedbba73fc *man/endsWith.Rd 4ad72c0183de86f7435b66fdd617dbf2 *man/file.info.Rd f0364a969e7687778d4b2e2a651612a0 *man/file.size.Rd 28cd0eaf06e1bb3ef808783fc9f217b2 *man/get0.Rd f6d4b60d090845baa1d66917e6c649ae *man/hasName.Rd 82c1d09b33edcb8c578c9452f0ff621a *man/import.Rd 0ef694f3021e07f821b76875888c6702 *man/isFALSE.Rd f415d30f4a3d44535d0284772c3da60a *man/isNamespaceLoaded.Rd f066fb3e9ac733f714e68ee655df099d *man/isTRUE.Rd 3193f8a1b410c99da87cdfd2306e4741 *man/lengths.Rd 43983f6cda7904738876df3fa5ae6f19 *man/list2DF.Rd 74c56e6a9d2e37c3bb6234ccf1f01b44 *man/paste.Rd 43841fff08714a10e37c67c48a5efd67 *man/paste0.Rd 70614d95852850d6397d3b8ba989bdee *man/removeSource.Rd 0a5e953c05afce33ff2f200ce43cb536 *man/startsWith.Rd 74454413551ad2fe17d32e3e5e31d5df *man/stopifnot.Rd 2647092889aef0ff7d93077dd3ee1f5c *man/str2expression.Rd 8ec5b025dd692bb1d3bda04626086d2a *man/str2lang.Rd 71dccde721e5e07b058ea9988d2aa758 *man/strrep.Rd 7b35b49308e1e7291350c0541be8d0d7 *man/suppressWarnings.Rd 44c533774b88159cbd550b9d842d65a2 *man/trimws.Rd f2ab99b5fe125ca043a77b89ff74bcf5 *man/valid.factor.Rd 636be43bf723e385435321ffed55f176 *man/vignetteInfo.Rd a9c2a5a46917fa75d978f04b1eeb3b16 *man/warningCondition.Rd d59274bb19ef27e3774e9d1bed9fb93e *src/dotsElt.c dea82a2ee366ce1253864931672df2cd *src/dotsLength.c 747eb6ee7c6060d846601e3ae4b8582b *src/dotsNames.c 1c4098d3f662615ed26268422e84ae5e *src/init.c 070b0a063bc14f81216f936fb895aac2 *tests/helper/helper.R a0cf596bf842ac7cab73d837ee3474b7 *tests/test_R_user_dir.R 472c0a48b52a2cf6f60d468ffe85afc8 *tests/test_URLencode.R 1b97afed1a49ba2f7e7588661dd78481 *tests/test_anyNA.R 4099f5f989efacd5650a8ecee103a337 *tests/test_asplit.R cdfdb1d1a0d354ef4cccf55d5c761268 *tests/test_capture.output.R 73d6561fbcd5c310a6ac298d76366462 *tests/test_dQuote.R 23a1a69bf7aac5601ac82f63d8e046d7 *tests/test_deparse1.R d012f4fc8d451334726a1609bb6d0584 *tests/test_dir.exists.R ff243305cbfd7c6c20dcf75a8b2f9b2c *tests/test_dotsElt.R 18ccf5227a80053f5b65dea32dff8562 *tests/test_dotsLength.R de4e907174f518488cfd4bfa1091d9fb *tests/test_dotsNames.R d20ca8e00de706dfca77fc4e7e079a30 *tests/test_file.info.R 8863972af374c21d56ea2625f357d1c1 *tests/test_file.mode.R 80309a60390999f8c875299d5343311a *tests/test_file.mtime.R 608d8ef6d47fde8c311efeb92600e7c5 *tests/test_file.size.R 8bbb0281ed2c45c26a8b1fe8829a8426 *tests/test_get0.R 224c4b67349277afb9ab178127d03470 *tests/test_hasName.R d8037fd4dfd75db762b138fe8e74cab3 *tests/test_isFALSE.R 9fef1041765a8612c73e04539bbaa479 *tests/test_isNamespaceLoaded.R 6bfeb283a68c31874f2368bc1845fc0c *tests/test_isTRUE.R 01ea7785d2d97d7364427f69ee028e43 *tests/test_lengths.R 5b26f503c05074ce2524adeda18d3338 *tests/test_list2DF.R 00a8645d02dadda4791d59a7583c8452 *tests/test_paste.R dcc12c9d11b7e6eb0b595695426e1f41 *tests/test_removeSource.R f5a7d4c6f5a89cd18a06029135ad1e57 *tests/test_startsWith.R 8d2777be3c8d6bc1121cf3f35506ee13 *tests/test_stopifnot.R 13f0e147e70337373583fb5361c512b7 *tests/test_str2expression.R 5c66a69aca9736c82b1b77b6fe66184a *tests/test_str2lang.R f7bb3f7fe9fcfd990f6090c5fce29870 *tests/test_strrep.R f62529aa2b845343c8442f2a0e005698 *tests/test_suppressWarnings.R 7ff35bbbb455c565d8ebcac87a015d22 *tests/test_trimws.R 89fd82c6ff2f443f75a69210c9acd26b *tests/test_valid.factor.R 48b5e09cb37ff576bca7627146b1fb73 *tests/test_warningCondition.R