This function computes the k-fold partitioning of a vector. Each record in a vector is randomly assigned to a group. Group numbers are between 1 and k.
Usage
kfold(constrain,k=10)
Arguments
constrain
a vector of labels.
k
number of groups.
Value
A vector with group assignmnets.
Author(s)
Stefano Cacciatore and Leonardo Tenori
Examples
kfold(1:100, k=10)
kfold(rep(1:20,each=5), k=10)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(KODAMA)
Loading required package: e1071
Loading required package: plsgenomics
Loading required package: MASS
Loading required package: boot
Loading required package: parallel
Loading required package: class
Attaching package: 'KODAMA'
The following object is masked from 'package:plsgenomics':
transformy
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/KODAMA/kfold.Rd_%03d_medium.png", width=480, height=480)
> ### Name: kfold
> ### Title: k-Fold Partitioning
> ### Aliases: kfold
> ### Keywords: partitioning
>
> ### ** Examples
>
> kfold(1:100, k=10)
[1] 7 8 2 9 1 6 5 7 5 9 7 9 1 10 10 10 3 8 8 8 3 6 6 9 10
[26] 2 6 3 1 7 3 10 7 7 3 8 3 7 5 2 2 2 1 10 1 6 1 6 1 4
[51] 10 5 10 6 4 3 8 1 2 1 2 9 5 8 8 9 5 3 2 8 8 6 4 4 2
[76] 4 6 9 5 5 3 7 4 4 10 7 9 6 3 1 4 10 4 4 5 2 9 9 7 5
> kfold(rep(1:20,each=5), k=10)
[1] 7 7 7 7 7 8 8 8 8 8 3 3 3 3 3 8 8 8 8 8 4 4 4 4 4
[26] 9 9 9 9 9 5 5 5 5 5 1 1 1 1 1 5 5 5 5 5 10 10 10 10 10
[51] 2 2 2 2 2 7 7 7 7 7 6 6 6 6 6 2 2 2 2 2 10 10 10 10 10
[76] 1 1 1 1 1 9 9 9 9 9 4 4 4 4 4 3 3 3 3 3 6 6 6 6 6
>
>
>
>
>
> dev.off()
null device
1
>