From 8d817b1988b06a2a0fceb7d35e04cbc81227f07a Mon Sep 17 00:00:00 2001 From: maechler Date: Mon, 17 Feb 2025 10:35:55 +0000 Subject: [PATCH] use `gait` in some examples git-svn-id: https://svn.r-project.org/R/trunk@87729 00db46b3-68df-0310-9c12-caf00c1e9a41 --- doc/NEWS.Rd | 3 ++- src/library/graphics/man/matplot.Rd | 20 +++++++++++--------- src/library/utils/man/head.Rd | 24 ++++++++++++------------ tests/Examples/graphics-Ex.Rout.save | 26 +++++++++++++------------- 4 files changed, 38 insertions(+), 35 deletions(-) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 56646042042..e5112295b66 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -200,7 +200,8 @@ \item The documentation of \code{gamma} and \code{is.numeric} is more specific, thanks to the contributors of \PR{18677}. - \item New dataset \code{gait} thanks to \I{Heather Turner} and \I{Ella Kaye}. + \item New dataset \code{gait} thanks to \I{Heather Turner} and + \I{Ella Kaye}, used in examples. } } diff --git a/src/library/graphics/man/matplot.Rd b/src/library/graphics/man/matplot.Rd index d756f2b6e6b..82e2e4e0f9e 100644 --- a/src/library/graphics/man/matplot.Rd +++ b/src/library/graphics/man/matplot.Rd @@ -1,6 +1,6 @@ % File src/library/graphics/man/matplot.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2022 R Core Team +% Copyright 1995-2025 R Core Team % Distributed under GPL 2 or later \name{matplot} @@ -142,15 +142,9 @@ legend(1, 4, c(" Setosa Petals", " Setosa Sepals", "Versicolor Petals", "Versicolor Sepals"), pch = "sSvV", col = rep(c(2,4), 2)) -nam.var <- colnames(iris)[-5] -nam.spec <- as.character(iris[1+50*0:2, "Species"]) -iris.S <- array(NA, dim = c(50,4,3), - dimnames = list(NULL, nam.var, nam.spec)) -for(i in 1:3) iris.S[,,i] <- data.matrix(iris[1:50+50*(i-1), -5]) - -matplot(iris.S[, "Petal.Length",], iris.S[, "Petal.Width",], pch = "SCV", +matplot(iris3[, "Petal L.",], iris3[, "Petal W.",], pch = "SCV", col = rainbow(3, start = 0.8, end = 0.1), - sub = paste(c("S", "C", "V"), dimnames(iris.S)[[3]], + sub = paste(c("S", "C", "V"), dimnames(iris3)[[3]], sep = "=", collapse= ", "), main = "Fisher's Iris Data") par(op) @@ -167,6 +161,14 @@ matplot(ct, mSC, type = "b", main = "matplot(, y)") matplot(ct, mSC, type = "b", main = "matplot(, y)", xaxt="n") Axis(ct, side=1, at = ct[1+4*(0:24)]) +iS <- 1:3 # indices of subset +matplot(gait[, iS, 1], gait[, iS, 2], pch = "123", type = "b", + col = rainbow(3, start = 0.8, end = 0.1), + sub = paste(iS, dimnames(gait)[[2]][iS], + sep = "=", collapse= ", "), + xlab = "Hip angle", ylab = "Knee angle", + main = "Hip and knee angle while walking") + ## Also works for data frame columns: matplot(iris[1:50,1:4]) } diff --git a/src/library/utils/man/head.Rd b/src/library/utils/man/head.Rd index 2813d44b3e6..32f398cfd63 100644 --- a/src/library/utils/man/head.Rd +++ b/src/library/utils/man/head.Rd @@ -1,6 +1,6 @@ % File src/library/utils/man/head.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2024 R Core Team +% Copyright 1995-2025 R Core Team % Distributed under GPL 2 or later \name{head} @@ -21,7 +21,7 @@ \alias{tail.array} \alias{.checkHT} \description{ - Returns the first or last parts of a vector, matrix, table, data frame + Returns the first or last parts of a vector, matrix, array, table, data frame or function. Since \code{head()} and \code{tail()} are generic functions, they have been extended to other classes, including \code{"\link[stats]{ts}"} from \pkg{stats}. @@ -139,9 +139,9 @@ head(letters, n = -6L) head(freeny.x, n = 10L) head(freeny.y) -head(iris3) -head(iris3, c(6L, 2L)) -head(iris3, c(6L, -1L, 2L)) +head(gait) # 3d array +head(gait, c(6L, 2L)) +head(gait, c(6L, 2L, -1L)) tail(letters) tail(letters, n = -6L) @@ -151,14 +151,14 @@ tail(freeny.x) tail(freeny.x, n = c(4, 2)) tail(freeny.y) -tail(iris3) -tail(iris3, c(6L, 2L)) -tail(iris3, c(6L, -1L, 2L)) +tail(gait) +tail(gait, c(6L, 2L)) +tail(gait, c(6L, 2L, -1L)) -## iris with dimnames stripped -a3d <- iris3 ; dimnames(a3d) <- NULL -tail(a3d, c(6, -1, 2)) # keepnums = TRUE is default here! -tail(a3d, c(6, -1, 2), keepnums = FALSE) +## gait without dimnames --> keepnums showing original row/col numbers +a3 <- gait ; dimnames(a3) <- NULL +tail(a3, c(6, 2, -1))# keepnums = TRUE is default here! +tail(a3, c(6, 2, -1), keepnums = FALSE) ## data frame w/ a (non-standard) attribute: treeS <- structure(trees, foo = "bar") diff --git a/tests/Examples/graphics-Ex.Rout.save b/tests/Examples/graphics-Ex.Rout.save index fee57420c43..468e0172bd0 100644 --- a/tests/Examples/graphics-Ex.Rout.save +++ b/tests/Examples/graphics-Ex.Rout.save @@ -1,14 +1,12 @@ -R Under development (unstable) (2024-07-30 r86939) -- "Unsuffered Consequences" -Copyright (C) 2024 The R Foundation for Statistical Computing -Platform: aarch64-apple-darwin22.6.0 +R Under development (unstable) (2025-02-17 r87727) -- "Unsuffered Consequences" +Copyright (C) 2025 The R Foundation for Statistical Computing +Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. - Natural language support but running in an English locale - R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. @@ -1635,15 +1633,9 @@ List of 2 + "Versicolor Petals", "Versicolor Sepals"), + pch = "sSvV", col = rep(c(2,4), 2)) > -> nam.var <- colnames(iris)[-5] -> nam.spec <- as.character(iris[1+50*0:2, "Species"]) -> iris.S <- array(NA, dim = c(50,4,3), -+ dimnames = list(NULL, nam.var, nam.spec)) -> for(i in 1:3) iris.S[,,i] <- data.matrix(iris[1:50+50*(i-1), -5]) -> -> matplot(iris.S[, "Petal.Length",], iris.S[, "Petal.Width",], pch = "SCV", +> matplot(iris3[, "Petal L.",], iris3[, "Petal W.",], pch = "SCV", + col = rainbow(3, start = 0.8, end = 0.1), -+ sub = paste(c("S", "C", "V"), dimnames(iris.S)[[3]], ++ sub = paste(c("S", "C", "V"), dimnames(iris3)[[3]], + sep = "=", collapse= ", "), + main = "Fisher's Iris Data") > par(op) @@ -1660,6 +1652,14 @@ List of 2 > matplot(ct, mSC, type = "b", main = "matplot(, y)", xaxt="n") > Axis(ct, side=1, at = ct[1+4*(0:24)]) > +> iS <- 1:3 # indices of subset +> matplot(gait[, iS, 1], gait[, iS, 2], pch = "123", type = "b", ++ col = rainbow(3, start = 0.8, end = 0.1), ++ sub = paste(iS, dimnames(gait)[[2]][iS], ++ sep = "=", collapse= ", "), ++ xlab = "Hip angle", ylab = "Knee angle", ++ main = "Hip and knee angle while walking") +> > ## Also works for data frame columns: > matplot(iris[1:50,1:4]) >