Some {DescTools} | R Documentation |
For displaying the first and last elements of an object there are the functions head
and tail
. Sometimes one might want to see more randomly scattered elements. This function returns some random parts of a vector, matrix or a data frame. The order of the elements within the object will be preserved.
Some(x, n = 6L, ...)
## Default S3 method:
Some(x, n = 6L, ...)
## S3 method for class 'data.frame'
Some(x, n = 6L, ...)
## S3 method for class 'matrix'
Some(x, n = 6L, addrownums = TRUE, ...)
x |
an object |
n |
a single integer. If positive, size for the resulting
object: number of elements for a vector (including lists), rows for
a matrix or data frame or lines for a function. If negative, all but
the |
addrownums |
if there are no row names, create them from the row numbers. |
... |
arguments to be passed to or from other methods. |
For matrices, 2-dim tables and data frames, Some()
returns
some n
rows when n > 0
or all but the
some n
rows when n < 0
. Some.matrix()
is not exported (unlike head.matrix
).
If a matrix has no row names, then Some()
will add row names of
the form "[n,]"
to the result, so that it looks similar to the
last lines of x
when printed. Setting addrownums =
FALSE
suppresses this behaviour.
I desisted from implementing interfaces for tables, ftables and functions, as this would not make much sense.
An object (usually) like x
but generally smaller.
Andri Signorell, basically copying and just slightly modifying Patrick Burns and R-Core code.
Some(letters)
Some(letters, n = -6L)
Some(freeny.x, n = 10L)
Some(freeny.y)