Skip to content

Commit

Permalink
use gait in some examples
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87729 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Feb 17, 2025
1 parent 17047e0 commit 8d817b1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
3 changes: 2 additions & 1 deletion doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}

Expand Down
20 changes: 11 additions & 9 deletions src/library/graphics/man/matplot.Rd
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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)
Expand All @@ -167,6 +161,14 @@ matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, y)")
matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, 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])
}
Expand Down
24 changes: 12 additions & 12 deletions src/library/utils/man/head.Rd
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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}.
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
26 changes: 13 additions & 13 deletions tests/Examples/graphics-Ex.Rout.save
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -1660,6 +1652,14 @@ List of 2
> matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, 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])
>
Expand Down

0 comments on commit 8d817b1

Please sign in to comment.