Functions for handling represampling objects, i.e. lists of resampling objects.

as.represampling(object, ...)

# S3 method for class 'list'
as.represampling(object, ...)

# S3 method for class 'represampling'
print(x, ...)

is_represampling(object)

Arguments

object

object of class represampling, or a list to be coerced to this class.

...

currently not used.

x

object of class represampling.

Value

as.represampling methods return an object of class represampling with the contents of object.

Details

represampling objects are (names) lists of resampling objects. Such objects are typically created by partition_cv, partition_kmeans, represampling_disc_bootstrap and related functions.

In r-repeated k-fold cross-validation, for example, the corresponding represampling object has length r, and each of its r resampling objects has length k.

as.resampling_list coerces object to class represampling while coercing its elements to resampling objects. Some validity checks are performed.

Examples

# Muenchow et al. (2012), see ?ecuador
# Partitioning by elevation classes in 200 m steps:
fac <- factor(as.character(floor(ecuador$dem / 300)))
summary(fac)
#>  10   5   6   7   8   9 
#>   4  21 246 255 147  78 
parti <- as.resampling(fac)
# a list of lists specifying sets of training and test sets,
# using each factor at a time as the test set:
str(parti)
#> List of 6
#>  $ 10:List of 2
#>   ..$ train: int [1:747] 1 2 3 4 5 6 7 8 9 10 ...
#>   ..$ test : int [1:4] 535 566 684 734
#>  $ 5 :List of 2
#>   ..$ train: int [1:730] 1 2 3 4 5 6 7 8 9 10 ...
#>   ..$ test : int [1:21] 42 77 93 106 115 139 250 332 385 405 ...
#>  $ 6 :List of 2
#>   ..$ train: int [1:505] 2 4 7 8 9 12 13 14 15 17 ...
#>   ..$ test : int [1:246] 1 3 5 6 10 11 16 19 23 29 ...
#>  $ 7 :List of 2
#>   ..$ train: int [1:496] 1 3 5 6 7 8 10 11 12 13 ...
#>   ..$ test : int [1:255] 2 4 9 18 20 22 24 26 28 30 ...
#>  $ 8 :List of 2
#>   ..$ train: int [1:604] 1 2 3 4 5 6 7 9 10 11 ...
#>   ..$ test : int [1:147] 8 12 14 15 21 25 27 32 46 54 ...
#>  $ 9 :List of 2
#>   ..$ train: int [1:673] 1 2 3 4 5 6 8 9 10 11 ...
#>   ..$ test : int [1:78] 7 13 17 35 44 75 78 79 88 97 ...
#>  - attr(*, "class")= chr "resampling"
summary(parti)
#>    n.train n.test
#> 10     747      4
#> 5      730     21
#> 6      505    246
#> 7      496    255
#> 8      604    147
#> 9      673     78