get_folds: Data partition into folds of the same size

View source: R/get_folds.R

Create partitionsR Documentation

Data partition into folds of the same size

Description

Create a random data partition of size n into k non-overlapping folds of approximately the same size

Usage

get_folds(n, k = 5L, nCV = 1L, seed = NULL)
        

Arguments

n

(integer) Sample size

k

(integer) Number of folds

nCV

(integer) Number of different partitions to be created

seed

(integer vector) Optional seed for randomization (see help(set.seed)). It has to be of length equal to nCV

Value

Returns a matrix with n rows and nCV columns. Each column contains a partition with k folds.

Examples

  require(SFSI)
  
  # Create 5 different partitions into 10 folds
  # for a sample size equal to 115
  out = get_folds(n=115, k=10, nCV=5)
  
  # Size of folds at first partition
  table(out[,1])
  

SFSI documentation built on Sept. 11, 2024, 9:11 p.m.