Debian Codegraph @

R/backports.R

raw
1
2 if (is.null(.BaseNamespaceEnv$isNamespaceLoaded)) {
3
4 isNamespaceLoaded <- function(name) {
5 name %in% loadedNamespaces()
6 }
7
8 }
9
10 if (is.null(.BaseNamespaceEnv$dir.exists)) {
11
12 dir.exists <- function(paths) {
13 info <- suppressWarnings(file.info(paths, extra_cols = FALSE))
14 info$isdir %in% TRUE
15 }
16
17 }
18
19 if (is.null(.BaseNamespaceEnv$lengths)) {
20
21 lengths <- function(x, use.names = TRUE) {
22 vapply(x, length, numeric(1), USE.NAMES = use.names)
23 }
24
25 }
26
27 if (is.null(.BaseNamespaceEnv$startsWith)) {
28
29 startsWith <- function(x, prefix) {
30 pattern <- sprintf("^\\Q%s\\E", prefix)
31 grepl(pattern, x, perl = TRUE)
32 }
33
34 }
35
36 if (is.null(.BaseNamespaceEnv$endsWith)) {
37
38 endsWith <- function(x, suffix) {
39 pattern <- sprintf("\\Q%s\\E$", suffix)
40 grepl(pattern, x, perl = TRUE)
41 }
42
43 }
44