git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Biobase@111612 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -8,7 +8,7 @@ importFrom(BiocGenerics, |
8 | 8 |
annotation, "annotation<-" |
9 | 9 |
) |
10 | 10 |
|
11 |
-importFrom(utils, head) |
|
11 |
+importFrom(utils, head, tail) |
|
12 | 12 |
|
13 | 13 |
exportClasses(aggregator, container, eSet, |
14 | 14 |
MIAxE, MIAME, characterORMIAME, |
... | ... |
@@ -62,3 +62,4 @@ export(.DollarNames.eSet, |
62 | 62 |
lcSuffix, lcPrefix, lcPrefixC, updateOldESet, userQuery, |
63 | 63 |
validMsg, write.AnnotatedDataFrame) |
64 | 64 |
S3method(head, "AnnotatedDataFrame") |
65 |
+S3method(tail, "AnnotatedDataFrame") |
... | ... |
@@ -115,9 +115,8 @@ setMethod("annotatedDataFrameFrom", |
115 | 115 |
signature(object="AssayData"), |
116 | 116 |
annotatedDataFrameFromAssayData) |
117 | 117 |
|
118 |
-head.AnnotatedDataFrame <- |
|
119 |
- function(x, n=6L, ...) |
|
120 |
-{ |
|
118 |
+head.AnnotatedDataFrame <- function(x, n=6L, ...) { |
|
119 |
+ ## essentially, utils:::head.data.frame |
|
121 | 120 |
stopifnot(length(x) == 1L) |
122 | 121 |
n <- if (n < 0L) { |
123 | 122 |
max(nrow(x) + n, 0L) |
... | ... |
@@ -125,6 +124,16 @@ head.AnnotatedDataFrame <- |
125 | 124 |
x[seq_len(n), ] |
126 | 125 |
} |
127 | 126 |
|
127 |
+tail.AnnotatedDataFrame <- function(x, n=6L, ...) { |
|
128 |
+ ## essentially, utils:::tail.data.frame |
|
129 |
+ stopifnot(length(x) == 1L) |
|
130 |
+ nrx <- nrow(x) |
|
131 |
+ n <- if (n < 0L) |
|
132 |
+ max(nrx + n, 0L) |
|
133 |
+ else min(n, nrx) |
|
134 |
+ x[seq.int(to = nrx, length.out = n), , drop = FALSE] |
|
135 |
+} |
|
136 |
+ |
|
128 | 137 |
setMethod("dimnames", "AnnotatedDataFrame", function(x) { |
129 | 138 |
dimnames(pData(x)) |
130 | 139 |
}) |
... | ... |
@@ -21,6 +21,7 @@ |
21 | 21 |
\alias{coerce,data.frame,AnnotatedDataFrame-method} |
22 | 22 |
\alias{coerce,phenoData,AnnotatedDataFrame-method} |
23 | 23 |
\alias{head.AnnotatedDataFrame} |
24 |
+\alias{tail.AnnotatedDataFrame} |
|
24 | 25 |
\alias{dim,AnnotatedDataFrame-method} |
25 | 26 |
\alias{dimnames,AnnotatedDataFrame-method} |
26 | 27 |
\alias{dimnames<-,AnnotatedDataFrame-method} |
... | ... |
@@ -162,9 +163,10 @@ an \code{AnnotatedDataFrame} from \code{\link{AssayData-class}}. |
162 | 163 |
\code{$<variable> <- <new_value>}:}{Replace or add a variable to |
163 | 164 |
\code{pData}. ... can include named arguments (especially |
164 | 165 |
\code{labelDescription}) to be added to \code{varMetadata}.} |
165 |
- \item{\code{head(<AnnotatedDataFrame>), n = 6L}}{Subset up to |
|
166 |
- \code{n} rows; negative \code{n} returns the first \code{nrow() - |
|
167 |
- n} rows.} |
|
166 |
+ \item{\code{head(<AnnotatedDataFrame>, n = 6L, ...)}, |
|
167 |
+ \code{tail(<AnnotatedDataFrame>, n=6L, ...)}}{Select the first |
|
168 |
+ (last for tail) \code{n} rows; negative \code{n} returns the first |
|
169 |
+ (last) \code{nrow() - n} rows.} |
|
168 | 170 |
\item{\code{dim(<AnnotatedDataFrame>)}, |
169 | 171 |
\code{ncol(<AnnotatedDataFrame>)}:}{Number of samples and |
170 | 172 |
variables (\code{dim}) and variables (\code{ncol}) in the |