Title: | Extracting a Data Portion |
---|---|
Description: | Provides a simple method to extract portions of a vector, matrix, or data.frame. The relative portion size and the way the portion is selected can be chosen. |
Authors: | Lennart Oelschläger [aut, cre] |
Maintainer: | Lennart Oelschläger <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0 |
Built: | 2024-12-19 05:07:51 UTC |
Source: | https://github.com/loelschlaeger/portion |
extract a portion of data saved as a vector
, matrix
,
data.frame
, or list
portion(x, proportion, how, centers = 2, ...) ## S3 method for class 'numeric' portion(x, proportion, how, centers = 2, ...) ## S3 method for class 'matrix' portion(x, proportion, how, centers = 2, byrow = TRUE, ignore = integer(), ...) ## S3 method for class 'data.frame' portion(x, proportion, how, centers = 2, byrow = TRUE, ignore = integer(), ...) ## S3 method for class 'list' portion(x, proportion, how, centers = 2, ...)
portion(x, proportion, how, centers = 2, ...) ## S3 method for class 'numeric' portion(x, proportion, how, centers = 2, ...) ## S3 method for class 'matrix' portion(x, proportion, how, centers = 2, byrow = TRUE, ignore = integer(), ...) ## S3 method for class 'data.frame' portion(x, proportion, how, centers = 2, byrow = TRUE, ignore = integer(), ...) ## S3 method for class 'list' portion(x, proportion, how, centers = 2, ...)
x |
an object to be portioned |
proportion |
a |
how |
a |
centers |
(only relevant if |
... |
further arguments to be passed to or from other methods |
byrow |
|
ignore |
(only relevant if |
the portioned input x
with the (row, column) indices used
added as attributes "indices"
# can portion vectors, matrices, data.frames, and lists of such types portion( list( 1:10, matrix(LETTERS[1:12], nrow = 3, ncol = 4), data.frame(a = 1:6, b = -6:-1) ), proportion = 0.5, how = "first" ) # can portion similar elements portion(c(rep(1, 5), rep(2, 5)), proportion = 0.5, how = "similar")
# can portion vectors, matrices, data.frames, and lists of such types portion( list( 1:10, matrix(LETTERS[1:12], nrow = 3, ncol = 4), data.frame(a = 1:6, b = -6:-1) ), proportion = 0.5, how = "first" ) # can portion similar elements portion(c(rep(1, 5), rep(2, 5)), proportion = 0.5, how = "similar")