
Last chance! 50% off unlimited learning
Sale ends in
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, …)
# S3 method for default
Some(x, n = 6L, …)
# S3 method for data.frame
Some(x, n = 6L, …)
# S3 method for matrix
Some(x, n = 6L, addrownums = TRUE, …)
an object
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 n
last/first number of elements of x
.
if there are no row names, create them from the row numbers.
arguments to be passed to or from other methods.
An object (usually) like x
but generally smaller.
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.
# NOT RUN {
Some(letters)
Some(letters, n = -6L)
Some(freeny.x, n = 10L)
Some(freeny.y)
# }
Run the code above in your browser using DataLab