backports/0000755000176200001440000000000015163645677012266 5ustar liggesusersbackports/tests/0000755000176200001440000000000015163412662013412 5ustar liggesusersbackports/tests/test_R_user_dir.R0000644000176200001440000000054715163407777016712 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_dotsNames.R0000644000176200001440000000126415163412662016534 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")) # issue 64 bp_...names = getFromNamespace("...names", "backports") test1 <- function(...) { ...names() } test2 <- function(...) { bp_...names() } expect_identical( test1("ABC"), test2("ABC") ) expect_identical( test1(a = "b", ), test2(a = "b", ) ) backports/tests/test_deparse1.R0000644000176200001440000000054215163407777016314 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_dotsElt.R0000644000176200001440000000101215163407777016217 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_str2lang.R0000644000176200001440000000041515163407777016343 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_dotlibPaths.R0000644000176200001440000000064415163407777017070 0ustar liggesuserssource("helper/helper.R") f = get(".libPaths", envir = baseenv()) expect_same = makeCompareFun(f, backports:::.libPaths) save <- .libPaths() f <- tempfile() expect_same(f) dir.create(f) expect_same(f) if (getRversion() >= "4.1.0") { expect_same(f, include.site = FALSE) } else { .libPaths(f, include.site = FALSE) expect_same() } .libPaths(save, include.site = length(.Library.site) && .Library.site %in% save) backports/tests/test_paste.R0000644000176200001440000000475715163407777015740 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_asplit.R0000644000176200001440000000046215163407777016105 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_valid.factor.R0000644000176200001440000000124115163407777017161 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_dotsLength.R0000644000176200001440000000101615163407777016720 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_str2expression.R0000644000176200001440000000043715163407777017625 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.R0000644000176200001440000000071015163407777017607 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_file.mtime.R0000644000176200001440000000037015163407777016640 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/test_hasName.R0000644000176200001440000000047315163407777016167 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_file.size.R0000644000176200001440000000036515163407777016503 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_anyNA.R0000644000176200001440000000061115163407777015613 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_lengths.R0000644000176200001440000000047115163407777016255 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_Rconcordance.R0000644000176200001440000000117015163407777017206 0ustar liggesuserssource("helper/helper.R") if (exists("as.Rconcordance", envir = asNamespace("tools"), inherits = FALSE)) { f <- get("as.Rconcordance", envir = asNamespace("tools")) expect_same <- makeCompareFun(f, backports:::as.Rconcordance.default) expect_same("") } if (exists("matchConcordance", envir = asNamespace("tools"), inherits = FALSE)) { f = get("matchConcordance", envir = asNamespace("tools")) expect_same = makeCompareFun(f, backports:::matchConcordance) conc <- tools::as.Rconcordance("") expect_same(20, conc) } backports/tests/test_warningCondition.R0000644000176200001440000000110615163407777020121 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_isNamespaceLoaded.R0000644000176200001440000000024115163407777020145 0ustar liggesuserssource("helper/helper.R") expect_true(isNamespaceLoaded("base")) expect_true(isNamespaceLoaded("backports")) expect_false(isNamespaceLoaded("..notexisting..")) backports/tests/test_URLencode.R0000644000176200001440000000064515163407777016434 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_trimws.R0000644000176200001440000000064515163407777016141 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_startsWith.R0000644000176200001440000000412315163407777016763 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_strrep.R0000644000176200001440000000201015163407777016117 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_dir.exists.R0000644000176200001440000000043615163407777016706 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_get0.R0000644000176200001440000000151215163407777015445 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/helper/0000755000176200001440000000000015163407777014704 5ustar liggesusersbackports/tests/helper/helper.R0000644000176200001440000000156315163407777016313 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_removeSource.R0000644000176200001440000000034415163407777017266 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_suppressWarnings.R0000644000176200001440000000043415163407777020205 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_isTRUE.R0000644000176200001440000000035315163407777015723 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_dQuote.R0000644000176200001440000000067015163407777016053 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_isFALSE.R0000644000176200001440000000035515163407777016000 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_null_coalesce.R0000644000176200001440000000022415163407777017415 0ustar liggesuserssource("helper/helper.R") expect_identical(NULL %||% TRUE, TRUE) expect_identical(FALSE %||% NULL, FALSE) expect_identical(FALSE %||% TRUE, FALSE) backports/tests/test_file.info.R0000644000176200001440000000056415163407777016465 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_file.mode.R0000644000176200001440000000036515163407777016455 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_stopifnot.R0000644000176200001440000000104315163407777016632 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_list2DF.R0000644000176200001440000000056715163407777016066 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/MD50000644000176200001440000001510015163645677012573 0ustar liggesusers8996e5f731940e1e6b95c576c7e4ff4b *DESCRIPTION 6187002963806292c9d8e1ec79b45896 *NAMESPACE 6d9388e6765a9c5b3923173e89f31498 *NEWS.md 35c58f655ad5194e8af81d851c58e719 *R/R_user_dir.R 563ce2bc12c47b698b8fd1b390b27b90 *R/Rconcordance.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 ed0bb4085860ad7431bf312c94248258 *R/import.R 71f82c7d4d76ea1bcf50c4882f2922a0 *R/isFALSE.R b6a23c8fa8e7b95266a59a8a9e9df3aa *R/isNamespaceLoaded.R 72a820a36c75b726315cdfb20fd025ac *R/isTRUE.R 7784e570a0e427a85eb0b54cc04d494c *R/lengths.R b79ae58d493ff912dde3efd15df65bd7 *R/libPaths.R 9fa4f27a194d3742a1089db9a0dbfb71 *R/list2DF.R 19b34ed7a3b0090726db82088ebe2146 *R/null_coalesce.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 f1ec157e58d129cd1099700ce24ca795 *R/zzz.R e05f3225bbc5ad6ab60fee0106da0385 *README.md e668b5dd4f52ce96df2cf5e26d976eac *man/R_user_dir.Rd 9502c207e8163009cd99aaacefd6f544 *man/URLencode.Rd 5c3ef8d8d05cd9f2b6d63210b5924faa *man/anyNA.Rd c6842d68782fe08de4368c642699ab25 *man/as.Rconcordance.Rd 7dae936cb33920428097b0225f4c4a07 *man/as.Rconcordance.default.Rd 3eb788d445602ef60f3e89bcbdf11dda *man/as.character.Rconcordance.Rd ea27c68a89fb392dbd5a2cdf6e301c84 *man/asplit.Rd 7448db6e5bd6c61ce7ca26aec4b29444 *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 a34085a669409b5a901ff7f041535bf6 *man/libPaths.Rd 43983f6cda7904738876df3fa5ae6f19 *man/list2DF.Rd a014a38ee99c32a6309086d2469cd81e *man/matchConcordance.Rd 7f8ac6aa816ce9cc96fedba9dd4d9534 *man/null_coalesce_operator.Rd 74c56e6a9d2e37c3bb6234ccf1f01b44 *man/paste.Rd 43841fff08714a10e37c67c48a5efd67 *man/paste0.Rd 01b2db9248014f9563930519cb8f94d8 *man/print.Rconcordance.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 f2144f330a48d825e9c0400a24741edf *src/dotsElt.c be9734284dd6ea0b039b42ca2def0ce4 *src/dotsLength.c 1388b756820072ddae9edf38b8fcc316 *src/dotsNames.c 1c4098d3f662615ed26268422e84ae5e *src/init.c 070b0a063bc14f81216f936fb895aac2 *tests/helper/helper.R a0cf596bf842ac7cab73d837ee3474b7 *tests/test_R_user_dir.R 85d258572afd961bc43629b7e6c4c741 *tests/test_Rconcordance.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 4d340dde3ed93644990d650c9b7e2ff1 *tests/test_dotlibPaths.R ff243305cbfd7c6c20dcf75a8b2f9b2c *tests/test_dotsElt.R 18ccf5227a80053f5b65dea32dff8562 *tests/test_dotsLength.R 51f17c715548a08b7de1dc5b7447e219 *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 97eee0ed8a3ae06dfc1b8f115c1c606a *tests/test_null_coalesce.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 backports/.aspell/0000755000176200001440000000000015163407777013621 5ustar liggesusersbackports/.aspell/backports.rds0000644000176200001440000000012515163407777016321 0ustar liggesusers‹‹àb```b`f’Ì@&ƒ³2°0piޤÄäì‚ü¢(ŸÓ Ê/† $¡ ¥fæ䤿¦æ•$–dæçÁ%ŠÐ%_U¶+zbackports/.aspell/defaults.R0000644000176200001440000000021415163407777015550 0ustar liggesusersRd_files <- vignettes <- R_files <- description <- list(encoding = "UTF-8", language = "en", dictionaries = c("en_stats", "backports")) backports/R/0000755000176200001440000000000015163412657012455 5ustar liggesusersbackports/R/paste.R0000644000176200001440000000141515163407777013724 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/asplit.R0000644000176200001440000000255515163407777014112 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/file.mode.R0000644000176200001440000000024515163407777014452 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/file.size.R0000644000176200001440000000133215163407777014476 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/capture.output.R0000644000176200001440000000346715163407777015623 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/trimws.R0000644000176200001440000000145115163407777014135 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/removeSource.R0000644000176200001440000000222315163407777015264 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/isFALSE.R0000644000176200001440000000102515163407777013773 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/deparse1.R0000644000176200001440000000111315163407777014307 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/vignetteInfo.R0000644000176200001440000000073715163407777015257 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/list2DF.R0000644000176200001440000000226415163407777014062 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/hasName.R0000644000176200001440000000103415163407777014161 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/null_coalesce.R0000644000176200001440000000116515163407777015422 0ustar liggesusers#' @title Backport of the null-coalescing operator for R < 4.4.0 #' @name null_coalesce_operator #' @rdname null_coalesce_operator #' #' @usage x \%||\% y #' #' @description #' See the original description in \code{Control}. #' #' @param x (any). #' @param y (any). #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.4.0") export(`%||%`) #' @examples #' # get function from namespace instead of possibly getting #' # implementation shipped with recent R versions: #' bp_null_coalesce = getFromNamespace("%||%", "backports") #' #' bp_null_coalesce(NULL, FALSE) "%||%" = function(x, y) { if (is.null(x)) y else x } backports/R/dotsLength.R0000644000176200001440000000110115163407777014713 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/import.R0000644000176200001440000000545115163407777014126 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.4.0" = "%||%", "4.3.0" = c("as.Rconcordance", "matchConcordance"), "4.1.0" = c("...names", ".libPaths"), "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", "str2lang", "str2expression"), "3.5.0" = c("...length", "...elt", "isFALSE", "isTRUE"), "3.4.0" = c("hasName", ".valid.factor"), "3.3.0" = c("startsWith", "endsWith", "strrep", "capture.output"), "3.2.0" = c("anyNA", "dir.exists", "file.size", "file.mode", "file.mtime", "lengths", "file.info", "URLencode", "isNamespaceLoaded", "trimws"), "3.1.0" = character(), "3.0.0" = character(), "0.0.0" = character() ) backports/R/strrep.R0000644000176200001440000000141015163407777014122 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/dir.exists.R0000644000176200001440000000101015163407777014673 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/R/dotsNames.R0000644000176200001440000000107715163412657014542 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/isNamespaceLoaded.R0000644000176200001440000000110315163407777016143 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/warningCondition.R0000644000176200001440000000174015163407777016125 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/zzz.R0000644000176200001440000000030015163407777013435 0ustar liggesusers#' @importFrom utils getFromNamespace head "_PACKAGE" .onUnload = function (libpath) { library.dynam.unload("backports", libpath) environment(.libPaths) <- environment(base::.libPaths) } backports/R/libPaths.R0000644000176200001440000000223215163407777014354 0ustar liggesusers#' @title Backport of .libPaths for R < 4.1.0 #' @rdname libPaths #' #' @description #' See the original description in \code{base::.libPaths}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.1.0") export(.libPaths) #' @examples #' save <- .libPaths() #' save #' # ignore the site library #' .libPaths("test", include.site = FALSE) #' #' # restore the original #' .libPaths(save) .libPaths <- local({ .lib.loc <- character() # This won't be used; see below function(new, include.site = TRUE) { if(!missing(new)) { ## paths don't really need to be unique, but searching ## large library trees repeatedly would be inefficient. ## Use normalizePath for display new <- Sys.glob(path.expand(new)) paths <- c(new, if(include.site) .Library.site, .Library) paths <- paths[dir.exists(paths)] .lib.loc <<- unique(normalizePath(paths, "/")) } else .lib.loc }}) # Run this in .onLoad: # environment(.libPaths) <- environment(base::.libPaths) # This will make our function see and modify the base # function's copy of .lib.loc. This relies on the # implementation in base, which has been the # same since R 1.6.0 or earlier. backports/R/get0.R0000644000176200001440000000200015163407777013436 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/file.info.R0000644000176200001440000000125315163407777014461 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/isTRUE.R0000644000176200001440000000130215163407777013716 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/dQuote.R0000644000176200001440000000473315163407777014057 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/endsWith.R0000644000176200001440000000122415163407777014373 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/stopifnot.R0000644000176200001440000000526215163407777014641 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/valid.factor.R0000644000176200001440000000132315163407777015162 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/suppressWarnings.R0000644000176200001440000000236315163407777016210 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/R_user_dir.R0000644000176200001440000000402215163407777014702 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/str2lang.R0000644000176200001440000000111415163407777014340 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/anyNA.R0000644000176200001440000000113115163407777013611 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/startsWith.R0000644000176200001440000000121515163407777014762 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/URLencode.R0000644000176200001440000000207415163407777014432 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/str2expression.R0000644000176200001440000000105215163407777015617 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/file.mtime.R0000644000176200001440000000025015163407777014635 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/paste0.R0000644000176200001440000000113515163407777014003 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/dotsElt.R0000644000176200001440000000110415163407777014221 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/Rconcordance.R0000644000176200001440000001574215163407777015220 0ustar liggesusers# These functions are taken from the R sources. # The original copyright notice was as follows: ## Copyright (C) 1995-2016 The R Core Team ## Copyright (C) 2022 Duncan Murdoch ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## A copy of the GNU General Public License is available at ## https://www.R-project.org/Licenses/ #' @title Backport of print.Rconcordance for R < 4.3.0 #' #' @description #' See the original description in \code{tools::print.Rconcordance}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.3.0") S3method("print", "Rconcordance") print.Rconcordance <- function(x, ...) { df <- data.frame(srcFile = x$srcFile, srcLine = x$srcLine) rownames(df) <- seq_len(nrow(df)) + x$offset print(df) invisible(x) } # This function converts concordance objects to string representations # of them. ## The string has three or four parts, separated by colons: ## 1. The output .tex filename ## 2. The input .Rnw filename ## 3. Optionally, the starting line number of the output coded as "ofs nn", ## where nn is the offset to the first output line. This is omitted if nn is 0. ## 4. The input line numbers corresponding to each output line. ## This are compressed using the following simple scheme: ## The first line number, followed by ## a run-length encoded diff of the rest of the line numbers. #' @title Backport of as.character.Rconcordance for R < 4.3.0 #' #' @description #' See the original description in \code{tools::as.character.Rconcordance}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.3.0") S3method("as.character", "Rconcordance") as.character.Rconcordance <- function(x, targetfile = "", ...) { concordance <- x offset <- concordance$offset src <- concordance$srcLine result <- character() srcfile <- rep_len(concordance$srcFile, length(src)) while (length(src)) { first <- src[1] if (length(unique(srcfile)) > 1) n <- which(srcfile != srcfile[1])[1] - 1 else n <- length(srcfile) vals <- with(rle(diff(src[seq_len(n)])), as.numeric(rbind(lengths, values))) result <- c(result, paste0("concordance:", targetfile, ":", srcfile[1], ":", if (offset) paste0("ofs ", offset, ":"), concordance$srcLine[1], " ", paste(vals, collapse = " ") )) offset <- offset + n drop <- seq_len(n) src <- src[-drop] srcfile <- srcfile[-drop] } result } #' @title Backport of as.Rconcordance for R < 4.3.0 #' #' @description #' See the original description in \code{tools::as.Rconcordance}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.3.0") export(as.Rconcordance) as.Rconcordance <- function(x, ...) { UseMethod("as.Rconcordance") } #' @title Backport of as.Rconcordance.default for R < 4.3.0 #' #' @description #' See the original description in \code{tools::as.Rconcordance}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.3.0") S3method("as.Rconcordance", "default") as.Rconcordance.default <- function(x, ...) { # clean comments etc. s <- sub("^.*(concordance){1}?", "concordance", sub("[^[:digit:]]*$", "", x)) s <- grep("^concordance:", s, value = TRUE) if (!length(s)) return(NULL) result <- stringToConcordance(s[1]) for (line in s[-1]) result <- addConcordance(result, line) result } # This takes one concordance string and produces a single concordance # object stringToConcordance <- function(s) { split <- strsplit(s, ":")[[1]] targetfile <- split[2] srcFile <- split[3] if (length(split) == 4) { ofs <- 0 vi <- 4 } else { ofs <- as.integer(sub("^ofs ([0-9]+)", "\\1", split[4])) vi <- 5 } values <- as.integer(strsplit(split[vi], " ")[[1]]) firstline <- values[1] rledata <- matrix(values[-1], nrow = 2) rle <- structure(list(lengths=rledata[1,], values=rledata[2,]), class="rle") diffs <- inverse.rle(rle) srcLines <- c(firstline, firstline + cumsum(diffs)) structure(list(offset = ofs, srcFile = srcFile, srcLine = srcLines), class = "Rconcordance") } # This modifies an existing concordance object to incorporate # one new concordance string addConcordance <- function(conc, s) { prev <- stringToConcordance(s) if (!is.null(prev)) { conc$srcFile <- rep_len(conc$srcFile, length(conc$srcLine)) i <- seq_along(prev$srcLine) conc$srcFile[prev$offset + i] <- prev$srcFile conc$srcLine[prev$offset + i] <- prev$srcLine } conc } # This modifies an existing concordance by following links specified # in a previous one. followConcordance <- function(conc, prevConcordance) { if (!is.null(prevConcordance)) { curLines <- conc$srcLine curFile <- rep_len(conc$srcFile, length(curLines)) curOfs <- conc$offset prevLines <- prevConcordance$srcLine prevFile <- rep_len(prevConcordance$srcFile, length(prevLines)) prevOfs <- prevConcordance$offset if (prevOfs) { prevLines <- c(rep(NA_integer_, prevOfs), prevLines) prevFile <- c(rep(NA_character_, prevOfs), prevFile) prevOfs <- 0 } n0 <- max(curLines) n1 <- length(prevLines) if (n1 < n0) { prevLines <- c(prevLines, rep(NA_integer_, n0 - n1)) prevFile <- c(prevFile, rep(NA_character_, n0 - n1)) } new <- is.na(prevLines[curLines]) conc$srcFile <- ifelse(new, curFile, prevFile[curLines]) conc$srcLine <- ifelse(new, curLines, prevLines[curLines]) } conc } #' @title Backport of matchConcordance for R < 4.3.0 #' #' @description #' See the original description in \code{tools::matchConcordance}. #' #' @keywords internal #' @rawNamespace if (getRversion() < "4.3.0") export(matchConcordance) matchConcordance <- function(linenum, concordance) { if (!all(c("offset", "srcLine", "srcFile") %in% names(concordance))) stop("concordance is not valid") linenum <- as.numeric(linenum) srcLines <- concordance$srcLine srcFile <- rep_len(concordance$srcFile, length(srcLines)) offset <- concordance$offset result <- matrix(character(), length(linenum), 2, dimnames = list(NULL, c("srcFile", "srcLine"))) for (i in seq_along(linenum)) { if (linenum[i] <= concordance$offset) result[i,] <- c("", "") else result[i,] <- c(srcFile[linenum[i] - offset], with(concordance, srcLine[linenum[i] - offset])) } result } backports/R/lengths.R0000644000176200001440000000111715163407777014253 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) { ans <- sapply(x, length, USE.NAMES = FALSE) if (!isTRUE(use.names)) { names(ans) <- NULL } ans } backports/src/0000755000176200001440000000000015163527772013050 5ustar liggesusersbackports/src/dotsElt.c0000644000176200001440000000145215163527757014637 0ustar liggesusers#include #include #include static void run_checks(Rboolean exists, int i, int n) { if (!exists) 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); } SEXP dotsElt(SEXP env_, SEXP i_) { int i = INTEGER(i_)[0]; #if defined(R_VERSION) && R_VERSION >= R_Version(4, 6, 0) run_checks(R_DotsExist(env_), i, R_DotsLength(env_)); return R_DotsElt(INTEGER(i_)[0], env_); #else SEXP ddd = findVar(R_DotsSymbol, env_); run_checks(ddd != R_UnboundValue, i, length(ddd)); ddd = nthcdr(ddd, i - 1); return eval(CAR(ddd), env_); #endif } backports/src/dotsLength.c0000644000176200001440000000111415163527757015327 0ustar liggesusers#include #include #include SEXP dotsLength(SEXP env_) { #if defined(R_VERSION) && R_VERSION >= R_Version(4, 6, 0) if (!R_DotsExist(env_)) { error("incorrect context: the current call has no '...' to look in"); } return ScalarInteger(R_DotsLength(env_)); #else 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); #endif } backports/src/init.c0000644000176200001440000000105315163407777014160 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/dotsNames.c0000644000176200001440000000220715163527757015155 0ustar liggesusers#include #include #include #define length_DOTS(_v_) (TYPEOF(_v_) == DOTSXP ? length(_v_) : 0) SEXP dotsNames(SEXP env) { #if defined(R_VERSION) && R_VERSION >= R_Version(4, 6, 0) if (!R_DotsExist(env)) error("incorrect context: the current call has no '...' to look in"); return R_DotsNames(env); #else SEXP vl = findVar(R_DotsSymbol, env); PROTECT(vl); if (vl == R_UnboundValue) error("incorrect context: the current call has no '...' to look in"); 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; #endif } #undef length_DOTS backports/NAMESPACE0000644000176200001440000000462415163407777013510 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) if (getRversion() < "4.1.0") export(.libPaths) if (getRversion() < "4.3.0") S3method("as.Rconcordance", "default") if (getRversion() < "4.3.0") S3method("as.character", "Rconcordance") if (getRversion() < "4.3.0") S3method("print", "Rconcordance") if (getRversion() < "4.3.0") export(as.Rconcordance) if (getRversion() < "4.3.0") export(matchConcordance) if (getRversion() < "4.4.0") export(`%||%`) importFrom(utils,getFromNamespace) importFrom(utils,head) useDynLib(backports,dotsElt) useDynLib(backports,dotsLength) useDynLib(backports,dotsNames) backports/NEWS.md0000644000176200001440000000711615163527757013367 0ustar liggesusers# backports 1.5.1 * Removed calls to deprecated C API functions for R 4.6.0. # backports 1.5.0 * Added backport for the null-coalesce operator `%||%` for R versions prior to 4.4.0. * `lengths()` now also works for long vectors (#64, thanks to @HughParsonage) # 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/README.md0000644000176200001440000001077715163407777013556 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()` * `base::.libPaths()` ## Backports for R versions prior to 4.3.0 * `tools:::print.Rconcordance` * `tools:::as.character.Rconcordance` * `tools::as.Rconcordance` * `tools:::as.Rconcordance.default` * `tools::matchConcordance` backports/man/0000755000176200001440000000000015163407777013036 5ustar liggesusersbackports/man/dotsNames.Rd0000644000176200001440000000077515163407777015273 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/str2lang.Rd0000644000176200001440000000073415163407777015065 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/strrep.Rd0000644000176200001440000000072015163407777014643 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/print.Rconcordance.Rd0000644000176200001440000000053315163407777017061 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/Rconcordance.R \name{print.Rconcordance} \alias{print.Rconcordance} \title{Backport of print.Rconcordance for R < 4.3.0} \usage{ \method{print}{Rconcordance}(x, ...) } \description{ See the original description in \code{tools::print.Rconcordance}. } \keyword{internal} backports/man/dotsElt.Rd0000644000176200001440000000076515163407777014753 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/isTRUE.Rd0000644000176200001440000000121015163407777014432 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/R_user_dir.Rd0000644000176200001440000000103615163407777015422 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/dotsLength.Rd0000644000176200001440000000077615163407777015452 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/as.character.Rconcordance.Rd0000644000176200001440000000061715163407777020266 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/Rconcordance.R \name{as.character.Rconcordance} \alias{as.character.Rconcordance} \title{Backport of as.character.Rconcordance for R < 4.3.0} \usage{ \method{as.character}{Rconcordance}(x, targetfile = "", ...) } \description{ See the original description in \code{tools::as.character.Rconcordance}. } \keyword{internal} backports/man/paste0.Rd0000644000176200001440000000104115163407777014515 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/URLencode.Rd0000644000176200001440000000115515163407777015147 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/valid.factor.Rd0000644000176200001440000000103015163407777015673 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/warningCondition.Rd0000644000176200001440000000132515163407777016642 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/startsWith.Rd0000644000176200001440000000100515163407777015475 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/dir.exists.Rd0000644000176200001440000000076315163407777015427 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/paste.Rd0000644000176200001440000000104315163407777014437 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/lengths.Rd0000644000176200001440000000075115163407777014774 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/as.Rconcordance.Rd0000644000176200001440000000050215163407777016324 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/Rconcordance.R \name{as.Rconcordance} \alias{as.Rconcordance} \title{Backport of as.Rconcordance for R < 4.3.0} \usage{ as.Rconcordance(x, ...) } \description{ See the original description in \code{tools::as.Rconcordance}. } \keyword{internal} backports/man/deparse1.Rd0000644000176200001440000000102115163407777015023 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/isFALSE.Rd0000644000176200001440000000074115163407777014515 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/backports-package.Rd0000644000176200001440000000201315163407777016702 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 Duncan Murdoch \email{murdoch.duncan@gmail.com} \item R Core Team } } backports/man/file.info.Rd0000644000176200001440000000113315163407777015174 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/trimws.Rd0000644000176200001440000000106215163407777014651 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/man/matchConcordance.Rd0000644000176200001440000000052515163407777016562 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/Rconcordance.R \name{matchConcordance} \alias{matchConcordance} \title{Backport of matchConcordance for R < 4.3.0} \usage{ matchConcordance(linenum, concordance) } \description{ See the original description in \code{tools::matchConcordance}. } \keyword{internal} backports/man/hasName.Rd0000644000176200001440000000076615163407777014712 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/file.size.Rd0000644000176200001440000000143315163407777015216 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/dQuote.Rd0000644000176200001440000000121415163407777014564 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/str2expression.Rd0000644000176200001440000000102515163407777016335 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/suppressWarnings.Rd0000644000176200001440000000142215163407777016721 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/endsWith.Rd0000644000176200001440000000076315163407777015120 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/list2DF.Rd0000644000176200001440000000130315163407777014571 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/vignetteInfo.Rd0000644000176200001440000000075115163407777015771 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/import.Rd0000644000176200001440000000276715163407777014653 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/isNamespaceLoaded.Rd0000644000176200001440000000106315163407777016666 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/removeSource.Rd0000644000176200001440000000077615163407777016015 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/as.Rconcordance.default.Rd0000644000176200001440000000055415163407777017756 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/Rconcordance.R \name{as.Rconcordance.default} \alias{as.Rconcordance.default} \title{Backport of as.Rconcordance.default for R < 4.3.0} \usage{ \method{as.Rconcordance}{default}(x, ...) } \description{ See the original description in \code{tools::as.Rconcordance}. } \keyword{internal} backports/man/get0.Rd0000644000176200001440000000110015163407777014154 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/null_coalesce_operator.Rd0000644000176200001440000000112415163407777020046 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/null_coalesce.R \name{null_coalesce_operator} \alias{null_coalesce_operator} \alias{\%||\%} \title{Backport of the null-coalescing operator for R < 4.4.0} \usage{ x \%||\% y } \arguments{ \item{x}{(any).} \item{y}{(any).} } \description{ See the original description in \code{Control}. } \examples{ # get function from namespace instead of possibly getting # implementation shipped with recent R versions: bp_null_coalesce = getFromNamespace("\%||\%", "backports") bp_null_coalesce(NULL, FALSE) } \keyword{internal} backports/man/capture.output.Rd0000644000176200001440000000131415163407777016326 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/libPaths.Rd0000644000176200001440000000070115163407777015071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/libPaths.R \name{.libPaths} \alias{.libPaths} \title{Backport of .libPaths for R < 4.1.0} \usage{ .libPaths(new, include.site = TRUE) } \description{ See the original description in \code{base::.libPaths}. } \examples{ save <- .libPaths() save # ignore the site library .libPaths("test", include.site = FALSE) # restore the original .libPaths(save) } \keyword{internal} backports/man/asplit.Rd0000644000176200001440000000074315163407777014625 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/stopifnot.Rd0000644000176200001440000000112715163407777015353 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/anyNA.Rd0000644000176200001440000000073515163407777014340 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/DESCRIPTION0000644000176200001440000000242615163645677014000 0ustar liggesusersPackage: backports Type: Package Title: Reimplementations of Functions Introduced Since R-3.0.0 Version: 1.5.1 Authors@R: c( person("Michel", "Lang", NULL, "michellang@gmail.com", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-9754-0393")), person("Duncan", "Murdoch", NULL, "murdoch.duncan@gmail.com", role = c("aut")), 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.3.3 Packaged: 2026-04-02 18:05:52 UTC; michel Author: Michel Lang [cre, aut] (ORCID: ), Duncan Murdoch [aut], R Core Team [aut] Repository: CRAN Date/Publication: 2026-04-03 05:10:23 UTC