Some.Rd
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, ...)
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.
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.
Some(letters)
#> [1] "d" "g" "h" "m" "t" "z"
Some(letters, n = -6L)
#> [1] "b" "c" "d" "f" "g" "h" "i" "j" "l" "m" "n" "p" "r" "s" "t" "v" "w" "x" "y"
#> [20] "z"
Some(freeny.x, n = 10L)
#> lag quarterly revenue price index income level market potential
#> [4,] 8.81486 4.68558 5.84046 12.9806
#> [5,] 8.81301 4.64019 5.85036 12.9831
#> [8,] 8.96161 4.61654 5.89763 12.9943
#> [9,] 8.96044 4.61407 5.92574 12.9992
#> [13,] 9.05871 4.57592 5.97805 13.0212
#> [14,] 9.10698 4.58661 6.00377 13.0265
#> [21,] 9.31378 4.50352 6.07103 13.0737
#> [24,] 9.39767 4.44924 6.10199 13.0918
#> [26,] 9.44223 4.42025 6.11596 13.0984
#> [37,] 9.71774 4.29627 6.18768 13.1579
Some(freeny.y)
#> [1] 8.79137 8.81486 9.23823 9.39767 9.53980 9.64390