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] "j" "n" "s" "u" "v" "y"
Some(letters, n = -6L)
#> [1] "c" "d" "f" "g" "h" "i" "j" "k" "l" "n" "p" "q" "r" "s" "t" "v" "w" "x" "y"
#> [20] "z"
Some(freeny.x, n = 10L)
#> lag quarterly revenue price index income level market potential
#> [2,] 8.79236 4.70217 5.82558 12.9733
#> [7,] 8.93673 4.61991 5.87769 12.9900
#> [13,] 9.05871 4.57592 5.97805 13.0212
#> [16,] 9.17096 4.57176 6.03475 13.0429
#> [25,] 9.42150 4.43966 6.11207 13.0950
#> [26,] 9.44223 4.42025 6.11596 13.0984
#> [28,] 9.52374 4.41151 6.12200 13.1169
#> [29,] 9.53980 4.39810 6.13119 13.1222
#> [32,] 9.64496 4.32770 6.15627 13.1415
#> [36,] 9.68683 4.30552 6.18231 13.1593
Some(freeny.y)
#> [1] 8.79137 8.96044 9.18665 9.35835 9.39767 9.44223