From f8cd030015c0c07c0c45c1526e2e6d195370fa3c Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 21 Jan 2024 17:31:19 -0800 Subject: [PATCH] fixes to examples running with only base attached --- src/library/base/man/Quotes.Rd | 2 +- src/library/base/man/Sys.getenv.Rd | 2 +- src/library/base/man/Trig.Rd | 2 +- src/library/base/man/as.POSIXlt.Rd | 2 +- src/library/base/man/balancePOSIXlt.Rd | 6 +++--- src/library/base/man/call.Rd | 6 ++++-- src/library/base/man/cbind.Rd | 4 ++-- src/library/base/man/chkDots.Rd | 1 + src/library/base/man/cut.POSIXt.Rd | 4 ++-- src/library/base/man/dimnames.Rd | 4 ++-- src/library/base/man/dput.Rd | 2 +- src/library/base/man/formals.Rd | 2 +- src/library/base/man/format.Rd | 2 +- src/library/base/man/formatc.Rd | 2 +- src/library/base/man/gzcon.Rd | 2 +- src/library/base/man/iconv.Rd | 2 +- src/library/base/man/identical.Rd | 2 +- src/library/base/man/ifelse.Rd | 2 +- src/library/base/man/library.dynam.Rd | 1 + src/library/base/man/list2env.Rd | 3 ++- src/library/base/man/locales.Rd | 2 +- src/library/base/man/match.Rd | 4 ++-- src/library/base/man/nchar.Rd | 2 +- src/library/base/man/parse.Rd | 2 +- src/library/base/man/pipeOp.Rd | 5 +++-- src/library/base/man/proc.time.Rd | 2 +- src/library/base/man/qr.Rd | 4 ++-- src/library/base/man/rawConversion.Rd | 3 ++- src/library/base/man/regmatches.Rd | 3 ++- src/library/base/man/substr.Rd | 2 +- src/library/base/man/textconnections.Rd | 1 + src/library/base/man/timezones.Rd | 1 + src/library/base/man/trace.Rd | 2 +- src/library/base/man/warnings.Rd | 2 +- 34 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/library/base/man/Quotes.Rd b/src/library/base/man/Quotes.Rd index 3e0781a96af..8f4445712cf 100644 --- a/src/library/base/man/Quotes.Rd +++ b/src/library/base/man/Quotes.Rd @@ -148,7 +148,7 @@ writeLines(x) # see also ?strwrap ## non-standard.) `x y` <- 1:5 `x y` -d <- data.frame(`1st column` = rchisq(5, 2), check.names = FALSE) +d <- data.frame(`1st column` = stats::rchisq(5, 2), check.names = FALSE) d$`1st column` ## Backslashes followed by up to three numbers are interpreted as diff --git a/src/library/base/man/Sys.getenv.Rd b/src/library/base/man/Sys.getenv.Rd index d9427b24be6..46db0bc154a 100644 --- a/src/library/base/man/Sys.getenv.Rd +++ b/src/library/base/man/Sys.getenv.Rd @@ -59,7 +59,7 @@ Sys.getenv(c("R_HOME", "R_PAPERSIZE", "R_PRINTCMD", "HOST")) s <- Sys.getenv() # *all* environment variables op <- options(width=111) # (nice printing) names(s) # all settings (the values could be very long) -head(s, 12) # using the Dlist print() method +utils::head(s, 12) # using the Dlist print() method ## Language and Locale settings -- but rather use Sys.getlocale() s[grep("^L(C|ANG)", names(s))] diff --git a/src/library/base/man/Trig.Rd b/src/library/base/man/Trig.Rd index d3f7a42927e..36e7ac69b64 100644 --- a/src/library/base/man/Trig.Rd +++ b/src/library/base/man/Trig.Rd @@ -116,7 +116,7 @@ x <- seq(-3, 7, by = 1/8) tx <- cbind(x, cos(pi*x), cospi(x), sin(pi*x), sinpi(x), tan(pi*x), tanpi(x), deparse.level=2) op <- options(digits = 4, width = 90) # for nice formatting -head(tx) +utils::head(tx) tx[ (x \%\% 1) \%in\% c(0, 0.5) ,] options(op) } diff --git a/src/library/base/man/as.POSIXlt.Rd b/src/library/base/man/as.POSIXlt.Rd index 5d6470a1ae2..db50bad9206 100644 --- a/src/library/base/man/as.POSIXlt.Rd +++ b/src/library/base/man/as.POSIXlt.Rd @@ -169,7 +169,7 @@ as.POSIXct(strptime("2010-10-31 01:30:00", "\%Y-\%m-\%d \%H:\%M:\%S")) unclass(z) # a large integer floor(unclass(z)/86400) # the number of days since 1970-01-01 (UTC) (now <- as.POSIXlt(Sys.time())) # the current datetime, as class "POSIXlt" -str(unclass(now)) # the internal list ; use now$hour, etc : +utils::str(unclass(now)) # the internal list ; use now$hour, etc : now$year + 1900 # see ?DateTimeClasses months(now); weekdays(now) # see ?months; using LC_TIME locale diff --git a/src/library/base/man/balancePOSIXlt.Rd b/src/library/base/man/balancePOSIXlt.Rd index fc27d8a85bb..ffeabc4cc4a 100644 --- a/src/library/base/man/balancePOSIXlt.Rd +++ b/src/library/base/man/balancePOSIXlt.Rd @@ -76,14 +76,14 @@ Sys.setenv(TZ = "UTC") d1 <- as.POSIXlt("2000-01-02 3:45") d1$min <- d1$min + (0:16)*20L (f1 <- format(d1)) -str(unclass(d1)) # only $min is of length > 1 +utils::str(unclass(d1)) # only $min is of length > 1 df <- balancePOSIXlt(d1, fill.only = TRUE) # a "POSIXlt" object -str(unclass(df)) # all of length 17; 'min' unchanged +utils::str(unclass(df)) # all of length 17; 'min' unchanged db <- balancePOSIXlt(d1, classed = FALSE) # a list stopifnot(identical( unCfillPOSIXlt(d1), balancePOSIXlt(d1, fill.only = TRUE, classed = FALSE))) -str(db) # of length 17 *and* in range +utils::str(db) # of length 17 *and* in range \dontshow{ stopifnot(exprs = { identical(f1, format(df)) diff --git a/src/library/base/man/call.Rd b/src/library/base/man/call.Rd index bf56daea153..0da1d36fbd7 100644 --- a/src/library/base/man/call.Rd +++ b/src/library/base/man/call.Rd @@ -121,8 +121,10 @@ g eval(g) ## Special calls (and some regular ones): -L <- as.list(E <- setNames( , c("if", "for", "while", "repeat", "function", - "(", "{", "[", "<-", "<<-", "->", "="))) +E <- c("if", "for", "while", "repeat", "function", + "(", "{", "[", "<-", "<<-", "->", "=") +names(E) <- E +L <- as.list(E) for(i in seq_along(L)) L[[i]] <- call(E[[i]]) # instead of lapply(E, call) .. list_ <- function (...) `names<-`(list(...), vapply(sys.call()[-1L], as.character, "")) (Tab <- noquote(sapply(list_(is.call, typeof, class, mode), \(F) sapply(L, F)))) diff --git a/src/library/base/man/cbind.Rd b/src/library/base/man/cbind.Rd index 7dfec1f44ac..a2bc40c346b 100644 --- a/src/library/base/man/cbind.Rd +++ b/src/library/base/man/cbind.Rd @@ -198,8 +198,8 @@ rbind(1:4, c = 2, "a++" = 10, dd, deparse.level = 1) # 3 rownames (default) rbind(1:4, c = 2, "a++" = 10, dd, deparse.level = 2) # 4 rownames ## cheap row names: -b0 <- gl(3,4, labels=letters[1:3]) -bf <- setNames(b0, paste0("o", seq_along(b0))) +b0 <- bf <- gl(3,4, labels=letters[1:3]) +names(bf) <- paste0("o", seq_along(b0)) df <- data.frame(a = 1, B = b0, f = gl(4,3)) df. <- data.frame(a = 1, B = bf, f = gl(4,3)) new <- data.frame(a = 8, B ="B", f = "1") diff --git a/src/library/base/man/chkDots.Rd b/src/library/base/man/chkDots.Rd index ca0c5f37e4e..adea8dd3c4d 100644 --- a/src/library/base/man/chkDots.Rd +++ b/src/library/base/man/chkDots.Rd @@ -29,6 +29,7 @@ seq.default ## <- you will see ' chkDots(...) ' seq(1,5, foo = "bar") # gives warning via chkDots() ## warning with more than one ...-entry: +require(stats) density.f <- function(x, ...) NextMethod("density") x <- density(structure(rnorm(10), class="f"), bar=TRUE, baz=TRUE) } diff --git a/src/library/base/man/cut.POSIXt.Rd b/src/library/base/man/cut.POSIXt.Rd index 13b0c4982e8..bd50d56fe06 100644 --- a/src/library/base/man/cut.POSIXt.Rd +++ b/src/library/base/man/cut.POSIXt.Rd @@ -71,9 +71,9 @@ cut(as.Date("2001/1/1") + 70*stats::runif(100), "weeks") # The standards all have midnight as the start of the day, but some # people incorrectly interpret it at the end of the previous day ... tm <- seq(as.POSIXct("2012-06-01 06:00"), by = "6 hours", length.out = 24) -aggregate(1:24, list(day = cut(tm, "days")), mean) +stats::aggregate(1:24, list(day = cut(tm, "days")), mean) # and a version with midnight included in the previous day: -aggregate(1:24, list(day = cut(tm, "days", right = TRUE)), mean) +stats::aggregate(1:24, list(day = cut(tm, "days", right = TRUE)), mean) } \keyword{manip} \keyword{chron} diff --git a/src/library/base/man/dimnames.Rd b/src/library/base/man/dimnames.Rd index 93f9ea7caad..d03f261a3f1 100644 --- a/src/library/base/man/dimnames.Rd +++ b/src/library/base/man/dimnames.Rd @@ -106,8 +106,8 @@ colnames0 <- function(x) dimnames(x)[[2]] A0 <- A; dimnames(A)[2:3] <- list(NULL) stopifnot(identical(A0, provideDimnames(A))) strd <- function(x) utils::str(dimnames(x)) -strd(provideDimnames(A, base= list(letters[-(1:9)], tail(LETTERS)))) -strd(provideDimnames(N, base= list(letters[-(1:9)], tail(LETTERS)))) # recycling +strd(provideDimnames(A, base= list(letters[-(1:9)], utils::tail(LETTERS)))) +strd(provideDimnames(N, base= list(letters[-(1:9)], utils::tail(LETTERS)))) # recycling strd(provideDimnames(A, base= list(c("AA","BB")))) # recycling on both levels ## set "empty dimnames": provideDimnames(rbind(1, 2:3), base = list(""), unique=FALSE) diff --git a/src/library/base/man/dput.Rd b/src/library/base/man/dput.Rd index 6a1a73f59bd..d3081e184a8 100644 --- a/src/library/base/man/dput.Rd +++ b/src/library/base/man/dput.Rd @@ -103,7 +103,7 @@ dget(fil) - xx # slight rounding on some platforms dput(xx, fil, control = "hexNumeric"); dget(fil) - xx unlink(fil) -xn <- setNames(xx, paste0("pi^",1:3)) +xn <- stats::setNames(xx, paste0("pi^",1:3)) dput(xn) # nicer, now "niceNames" being part of default 'control' dput(xn, control = "S_compat") # no names ## explicitly asking for output as in R < 3.5.0: diff --git a/src/library/base/man/formals.Rd b/src/library/base/man/formals.Rd index fb9d5666bec..cf154912c3e 100644 --- a/src/library/base/man/formals.Rd +++ b/src/library/base/man/formals.Rd @@ -64,7 +64,7 @@ names(formals(lm)) methods:: formalArgs(lm) # same ## formals returns a pairlist. Arguments with no default have type symbol (aka name). -str(formals(lm)) +utils::str(formals(lm)) ## formals returns NULL for primitive functions. Use it in combination with ## args for this case. diff --git a/src/library/base/man/format.Rd b/src/library/base/man/format.Rd index a87de7c9cc4..18bc7365c38 100644 --- a/src/library/base/man/format.Rd +++ b/src/library/base/man/format.Rd @@ -182,7 +182,7 @@ format(2^31-1) format(2^31-1, scientific = TRUE) ## scientific = numeric scipen (= {sci}entific notation {pen}alty) : x <- c(1e5, 1000, 10, 0.1, .001, .123) -t(sapply(setNames(,-4:1), +t(sapply(stats::setNames(,-4:1), \(sci) sapply(x, format, scientific=sci))) diff --git a/src/library/base/man/formatc.Rd b/src/library/base/man/formatc.Rd index 2b623cd730d..d8ed73aad81 100644 --- a/src/library/base/man/formatc.Rd +++ b/src/library/base/man/formatc.Rd @@ -297,7 +297,7 @@ stopifnot(pnv == "1+1i", pnv == format(zv), pnv == prettyNum(zv, drop0trailing = TRUE)) ## more digits change the picture: options(digits = 8) -head(fv <- format(zv), 3) +utils::head(fv <- format(zv), 3) prettyNum(fv) prettyNum(fv, drop0trailing = TRUE) # a bit nicer options(op) diff --git a/src/library/base/man/gzcon.Rd b/src/library/base/man/gzcon.Rd index 2ed5f3aadfe..8da6af717b0 100644 --- a/src/library/base/man/gzcon.Rd +++ b/src/library/base/man/gzcon.Rd @@ -55,7 +55,7 @@ z <- gzcon(url("https://www.stats.ox.ac.uk/pub/datasets/csb/ch12.dat.gz")) # read.table can only read from a text-mode connection. raw <- textConnection(readLines(z)) close(z) -dat <- read.table(raw) +dat <- utils::read.table(raw) close(raw) dat[1:4, ] } diff --git a/src/library/base/man/iconv.Rd b/src/library/base/man/iconv.Rd index c2c00efd9c8..49932422d7f 100644 --- a/src/library/base/man/iconv.Rd +++ b/src/library/base/man/iconv.Rd @@ -232,7 +232,7 @@ try(iconv(x, "latin1", "ASCII//TRANSLIT")) # platform-dependent iconv(x, "latin1", "ASCII", sub = "byte") ## and for Windows' 'Unicode' -str(xx <- iconv(x, "latin1", "UTF-16LE", toRaw = TRUE)) +utils::str(xx <- iconv(x, "latin1", "UTF-16LE", toRaw = TRUE)) iconv(xx, "UTF-16LE", "UTF-8") emoji <- "\U0001f604" diff --git a/src/library/base/man/identical.Rd b/src/library/base/man/identical.Rd index cd666568a6c..66a87eb6c54 100644 --- a/src/library/base/man/identical.Rd +++ b/src/library/base/man/identical.Rd @@ -157,7 +157,7 @@ identical(f, g) # TRUE, as bytecode is ignored by default identical(f, g, ignore.bytecode=FALSE) # FALSE: bytecode differs ## GLM families contain several functions, some of which share an environment: -p1 <- poisson() ; p2 <- poisson() +p1 <- stats::poisson() ; p2 <- stats::poisson() identical(p1, p2) # FALSE identical(p1, p2, ignore.environment=TRUE) # TRUE diff --git a/src/library/base/man/ifelse.Rd b/src/library/base/man/ifelse.Rd index 793253cc8eb..ab5762f2773 100644 --- a/src/library/base/man/ifelse.Rd +++ b/src/library/base/man/ifelse.Rd @@ -80,7 +80,7 @@ ifelse(x >= 0, sqrt(x), NA) x <- seq(as.Date("2000-02-29"), as.Date("2004-10-04"), by = "1 month") ## has many "yyyy-mm-29", but a few "yyyy-03-01" in the non-leap years y <- ifelse(as.POSIXlt(x)$mday == 29, x, NA) -head(y) # not what you expected ... ==> need restore the class attribute: +utils::head(y) # not what you expected ... ==> need restore the class attribute: class(y) <- class(x) y ## This is a (not atypical) case where it is better *not* to use ifelse(), diff --git a/src/library/base/man/library.dynam.Rd b/src/library/base/man/library.dynam.Rd index bf450f291c0..1607cfd669b 100644 --- a/src/library/base/man/library.dynam.Rd +++ b/src/library/base/man/library.dynam.Rd @@ -118,6 +118,7 @@ library.dynam() ## More on library.dynam.unload() : \donttest{require(nlme) +require(utils) nlme:::.onUnload # shows library.dynam.unload() call detach("package:nlme") # by default, unload=FALSE , so, tail(library.dynam(), 2)# nlme still there diff --git a/src/library/base/man/list2env.Rd b/src/library/base/man/list2env.Rd index 85124730590..fd597059d11 100644 --- a/src/library/base/man/list2env.Rd +++ b/src/library/base/man/list2env.Rd @@ -63,7 +63,8 @@ stopifnot(identical(L [sort.list(names(L ))], ## now add to e -- can be seen as a fast "multi-assign": list2env(list(abc = LETTERS, note = "just an example", - df = data.frame(x = rnorm(20), y = rbinom(20, 1, prob = 0.2))), + df = data.frame(x = stats::rnorm(20), + y = stats::rbinom(20, 1, prob = 0.2))), envir = e) utils::ls.str(e) } diff --git a/src/library/base/man/locales.Rd b/src/library/base/man/locales.Rd index bad990f741d..8e87678ff7d 100644 --- a/src/library/base/man/locales.Rd +++ b/src/library/base/man/locales.Rd @@ -197,7 +197,7 @@ Sys.setenv("LANGUAGE" = "es") # set the language for error/warning messages ##' show a "full" Sys.getlocale() nicely: showL <- function(loc) { sl <- strsplit(strsplit(loc, sep)[[1L]], "=") - setNames(sapply(sl, `[[`, 2L), sapply(sl, `[[`, 1L)) + stats::setNames(sapply(sl, `[[`, 2L), sapply(sl, `[[`, 1L)) } print.Dlist(lloc <- showL(Sys.getlocale())) ## R-supported ones (but LC_ALL): diff --git a/src/library/base/man/match.Rd b/src/library/base/man/match.Rd index cc600271d9e..3c2b7497987 100644 --- a/src/library/base/man/match.Rd +++ b/src/library/base/man/match.Rd @@ -126,8 +126,8 @@ unique(zN) # the "NA" and the 3 different non-NA NaN's stopifnot(identical(unique(zN), zN[c(1, 7,9,10)])) ## very strict equality would have 4 duplicates (of 12): -symnum(outer(zN, zN, Vectorize(identical,c("x","y")), - FALSE,FALSE,FALSE,FALSE)) +stats::symnum(outer(zN, zN, Vectorize(identical,c("x","y")), + FALSE,FALSE,FALSE,FALSE)) ## removing "(very strictly) duplicates", i <- c(5,8,11,12) # we get 8 pairwise non-identicals : Ixy <- outer(zN[-i], zN[-i], Vectorize(identical,c("x","y")), diff --git a/src/library/base/man/nchar.Rd b/src/library/base/man/nchar.Rd index 0860b14ba02..2cad394a7a3 100644 --- a/src/library/base/man/nchar.Rd +++ b/src/library/base/man/nchar.Rd @@ -153,7 +153,7 @@ nchar(deparse(mean)) # 18 17 <-- unless mean differs from base::mean ## NA behaviour as function of keepNA=* : -logi <- setNames(, c(FALSE, NA, TRUE)) +logi <- stats::setNames(, c(FALSE, NA, TRUE)) sapply(logi, \(k) data.frame(nchar = nchar (NA, keepNA=k), nzchar = nzchar(NA, keepNA=k))) diff --git a/src/library/base/man/parse.Rd b/src/library/base/man/parse.Rd index 2bcb7b502cd..6beebfffb95 100644 --- a/src/library/base/man/parse.Rd +++ b/src/library/base/man/parse.Rd @@ -192,7 +192,7 @@ an error " sf <- srcfile("txt") tryCatch(parse(text = txt, srcfile = sf), error = function(e) "Syntax error.") -getParseData(sf) +utils::getParseData(sf) } \keyword{file} \keyword{programming} diff --git a/src/library/base/man/pipeOp.Rd b/src/library/base/man/pipeOp.Rd index 9164f48de68..00232ebbab0 100644 --- a/src/library/base/man/pipeOp.Rd +++ b/src/library/base/man/pipeOp.Rd @@ -59,8 +59,9 @@ } \examples{ # simple uses: -mtcars |> head() # same as head(mtcars) -mtcars |> head(2) # same as head(mtcars, 2) +require(utils) +mtcars |> head() # same as head(mtcars) +mtcars |> head(2) # same as head(mtcars, 2) mtcars |> subset(cyl == 4) |> nrow() # same as nrow(subset(mtcars, cyl == 4)) # to pass the lhs into an argument other than the first, either diff --git a/src/library/base/man/proc.time.Rd b/src/library/base/man/proc.time.Rd index c2199864d54..ced5563a766 100644 --- a/src/library/base/man/proc.time.Rd +++ b/src/library/base/man/proc.time.Rd @@ -66,7 +66,7 @@ proc.time() \examples{\donttest{ ## a way to time an R expression: system.time is preferred ptm <- proc.time() -for (i in 1:50) mad(stats::runif(500)) +for (i in 1:50) stats::mad(stats::runif(500)) proc.time() - ptm }} \keyword{utilities} diff --git a/src/library/base/man/qr.Rd b/src/library/base/man/qr.Rd index c4ca18de7ba..3478d015637 100644 --- a/src/library/base/man/qr.Rd +++ b/src/library/base/man/qr.Rd @@ -169,14 +169,14 @@ h9 \%*\% x # = y ## overdetermined system -A <- matrix(runif(12), 4) +A <- matrix(stats::runif(12), 4) b <- 1:4 qr.solve(A, b) # or solve(qr(A), b) solve(qr(A, LAPACK = TRUE), b) # this is a least-squares solution, cf. lm(b ~ 0 + A) ## underdetermined system -A <- matrix(runif(12), 3) +A <- matrix(stats::runif(12), 3) b <- 1:3 qr.solve(A, b) solve(qr(A, LAPACK = TRUE), b) diff --git a/src/library/base/man/rawConversion.Rd b/src/library/base/man/rawConversion.Rd index e89752ce58a..32374b8a75e 100644 --- a/src/library/base/man/rawConversion.Rd +++ b/src/library/base/man/rawConversion.Rd @@ -113,6 +113,7 @@ stopifnot(exprs = { identical(packBits( 0:31) , packBits(as.raw(0:31))) }) +require(utils) str(pBi <- packBits(intToBits(i))) data.frame(B = matrix(pBi, nrow=6, byrow=TRUE), hex = format(as.hexmode(i)), i) @@ -147,7 +148,7 @@ bitC(1+2^-(1:53))# from 0.5 converge to 1 d2bI <- function(x) vapply(as.double(x), function(x) intToBits(numToInts(x)), raw(64L)) d2b <- function(x) vapply(as.double(x), function(x) numToBits(x) , raw(64L)) set.seed(1) -x <- c(sort(rt(2048, df=1.5)), 2^(-10:10), 1+2^-(1:53)) +x <- c(sort(stats::rt(2048, df=1.5)), 2^(-10:10), 1+2^-(1:53)) str(bx <- d2b(x)) # a 64 x 2122 raw matrix stopifnot( identical(bx, d2bI(x)) ) diff --git a/src/library/base/man/regmatches.Rd b/src/library/base/man/regmatches.Rd index a217b79915b..8bb736f68ee 100644 --- a/src/library/base/man/regmatches.Rd +++ b/src/library/base/man/regmatches.Rd @@ -123,6 +123,7 @@ z ## With `perl = TRUE` and `invert = FALSE` capture group names ## are preserved. Collect functions and arguments in calls: +require(utils) NEWS <- head(readLines(file.path(R.home(), 'doc', 'NEWS.2')), 100) m <- gregexec("(?\\\\w+)\\\\((?[^)]*)\\\\)", NEWS, perl = TRUE) y <- regmatches(NEWS, m) @@ -130,7 +131,7 @@ y[[16]] ## Make tabular, adding original line numbers mdat <- as.data.frame(t(do.call(cbind, y))) mdat <- cbind(mdat, line=rep(seq_along(y), lengths(y) / ncol(mdat))) -head(mdat) +utils::head(mdat) NEWS[head(mdat[['line']])] } \keyword{character} diff --git a/src/library/base/man/substr.Rd b/src/library/base/man/substr.Rd index cf9d5b6dc58..0830d34126e 100644 --- a/src/library/base/man/substr.Rd +++ b/src/library/base/man/substr.Rd @@ -102,7 +102,7 @@ substring(x, 2, 4:6) X <- x names(X) <- LETTERS[seq_along(x)] comment(X) <- noquote("is a named vector") -str(aX <- attributes(X)) +utils::str(aX <- attributes(X)) substring(x, 2) <- c("..", "+++") substring(X, 2) <- c("..", "+++") X diff --git a/src/library/base/man/textconnections.Rd b/src/library/base/man/textconnections.Rd index 8dc0b01711b..8a4f6b6001e 100644 --- a/src/library/base/man/textconnections.Rd +++ b/src/library/base/man/textconnections.Rd @@ -125,6 +125,7 @@ trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) weight <- c(ctl, trt) sink(zz) +require(stats) anova(lm.D9 <- lm(weight ~ group)) cat("\nSummary of Residuals:\n\n") summary(resid(lm.D9)) diff --git a/src/library/base/man/timezones.Rd b/src/library/base/man/timezones.Rd index 186b81d3efa..8803ca30333 100644 --- a/src/library/base/man/timezones.Rd +++ b/src/library/base/man/timezones.Rd @@ -327,6 +327,7 @@ OlsonNames(tzdir = NULL) } \examples{ +require(utils) Sys.timezone() str(OlsonNames()) ## typically around six hundred names, diff --git a/src/library/base/man/trace.Rd b/src/library/base/man/trace.Rd index 0bd817394c5..906c7a3d666 100644 --- a/src/library/base/man/trace.Rd +++ b/src/library/base/man/trace.Rd @@ -255,7 +255,7 @@ require(stats) ## Very simple use trace(sum) -hist(rnorm(100)) # shows about 3-4 calls to sum() +graphics::hist(rnorm(100)) # shows about 3-4 calls to sum() untrace(sum) ## Show how pt() is called from inside power.t.test(): diff --git a/src/library/base/man/warnings.Rd b/src/library/base/man/warnings.Rd index 4751ef12c5d..0e88d39329d 100644 --- a/src/library/base/man/warnings.Rd +++ b/src/library/base/man/warnings.Rd @@ -89,7 +89,7 @@ for(w in -1:1) { } ## at the end prints all three warnings, from the 'option(warn = 0)' above options(ow) # reset to previous, typically 'warn = 0' -tail(warnings(), 2) # see the last two warnings only (via '[' method) +utils::tail(warnings(), 2) # see the last two warnings only (via '[' method) ## Often the most useful way to look at many warnings: summary(warnings())