Skip to content

Commit 7413f10

Browse files
author
pd
committed
add [.Pair method
git-svn-id: https://svn.r-project.org/R/trunk@88250 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent c17f2f2 commit 7413f10

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

doc/NEWS.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102

103103
\item Dataset \code{LifeCycleSavings} had a misspelled row name:
104104
\code{"Guatamala"} was corrected to \code{"Guatemala"}.
105+
106+
\item The \code{Pair(x,y)} construction in the formula interface to
107+
paired tests did not work with the \code{subset} argument, due to the
108+
absence of a \code{[.Pair} method, which has now been added.
105109
}
106110
}
107111

src/library/stats/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ S3method("[", formula)
115115
S3method("[", terms)
116116
S3method("[", ts)
117117
S3method("[", tskernel)
118+
S3method("[", Pair)
118119
S3method("[<-", ts)
119120
S3method("[[", dendrogram)
120121
S3method(add1, default)

src/library/stats/R/Pair.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,16 @@ Pair <- function(x,y) {
88
class(pp) <- "Pair"
99
pp
1010
}
11+
`[.Pair` <- function (x, i, j, drop = FALSE)
12+
{
13+
if (missing(j)) {
14+
x <- unclass(x)[i, , drop = FALSE]
15+
class(x) <- "Pair"
16+
x
17+
}
18+
else {
19+
class(x) <- "matrix"
20+
NextMethod("[")
21+
}
22+
}
23+

0 commit comments

Comments
 (0)