Description Usage Arguments Value Author(s) References See Also Examples
Selects the first n
elements of an object. The default method of the
convenience wrapper first
.
1 2 |
x |
|
n |
|
keep |
|
strict |
|
Subset of x
. Exact value depends on the class of x
.
Janko Thyson janko.thyson@gmail.com
http://github.com/rappster/selectr
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | ##------------------------------------------------------------------------------
## Vector //
##------------------------------------------------------------------------------
x <- letters
first(x)
first(x, 3)
first(x, 3, keep = TRUE)
## Conditions //
first(x, 30)
first(x, 30, strict = 1)
first(x, 30, strict = 2)
try(first(x, 30, strict = 3))
##------------------------------------------------------------------------------
## List //
##------------------------------------------------------------------------------
x <- as.list(letters)
first(x)
first(x, 3)
res <- first(x, 3, keep = TRUE)
attributes(res)
## Conditions //
first(x, 30)
first(x, 30, strict = 1)
first(x, 30, strict = 2)
try(first(x, 30, strict = 3))
##------------------------------------------------------------------------------
## Data frame //
##------------------------------------------------------------------------------
x <- data.frame(a= 1:5, b = letters[1:5], stringsAsFactors = FALSE)
## Rows:
first(x)
first(x, 3)
first(x, 3, keep = TRUE)
## Columns:
first(x, margin = 2)
first(x, 2, margin = 2)
first(x, 3, margin = 2)
first(x, margin = 2, drop = TRUE)
first(x, 2, margin = 2, drop = TRUE)
## Conditions:
first(x, 10)
first(x, 10, strict = 1)
first(x, 10, strict = 2)
try(first(x, 10, strict = 3))
first(x, 3, margin = 2)
first(x, 3, margin = 2, strict = 1)
first(x, 3, margin = 2, strict = 2)
try(first(x, 3, margin = 2, strict = 3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.