msplit: Split Vectors for Parallelization

Description Usage Arguments Details References See Also Examples

View source: R/msplit.R

Description

Aids in splitting of a vector for parallelization, e.g. splitting up a group of SNPs into subgroups, so each one can analyzed in a parallel process. Other uses might be to choose splitting points for k-fold cross validation.

Usage

1
msplit(vec, m)

Arguments

vec

A vector, e.g. c(1,2,3), 1:10.

m

Numer of splits.

Details

Returns a list, with each member being a subgroup to be parallelized.

References

Thomas J. Hoffmann (2011). Passing in Command Line Arguments and Parallel Cluster/Multicore Batching in R with batch. Journal of Statistical Software, Code Snippets, 39(1), 1-11. URL http://www.jstatsoft.org/v39/c01/.

See Also

parseCommandArgs, rbatch, mergeCsv

Examples

1
2
3
  snps <- paste("snp", 1:98, sep="")
  print(snps)
  print(msplit(snps, 10)) ## Splits it into 10 groups

Example output

 [1] "snp1"  "snp2"  "snp3"  "snp4"  "snp5"  "snp6"  "snp7"  "snp8"  "snp9" 
[10] "snp10" "snp11" "snp12" "snp13" "snp14" "snp15" "snp16" "snp17" "snp18"
[19] "snp19" "snp20" "snp21" "snp22" "snp23" "snp24" "snp25" "snp26" "snp27"
[28] "snp28" "snp29" "snp30" "snp31" "snp32" "snp33" "snp34" "snp35" "snp36"
[37] "snp37" "snp38" "snp39" "snp40" "snp41" "snp42" "snp43" "snp44" "snp45"
[46] "snp46" "snp47" "snp48" "snp49" "snp50" "snp51" "snp52" "snp53" "snp54"
[55] "snp55" "snp56" "snp57" "snp58" "snp59" "snp60" "snp61" "snp62" "snp63"
[64] "snp64" "snp65" "snp66" "snp67" "snp68" "snp69" "snp70" "snp71" "snp72"
[73] "snp73" "snp74" "snp75" "snp76" "snp77" "snp78" "snp79" "snp80" "snp81"
[82] "snp82" "snp83" "snp84" "snp85" "snp86" "snp87" "snp88" "snp89" "snp90"
[91] "snp91" "snp92" "snp93" "snp94" "snp95" "snp96" "snp97" "snp98"
[[1]]
 [1] "snp1"  "snp2"  "snp3"  "snp4"  "snp5"  "snp6"  "snp7"  "snp8"  "snp9" 
[10] "snp10"

[[2]]
 [1] "snp11" "snp12" "snp13" "snp14" "snp15" "snp16" "snp17" "snp18" "snp19"
[10] "snp20"

[[3]]
 [1] "snp21" "snp22" "snp23" "snp24" "snp25" "snp26" "snp27" "snp28" "snp29"
[10] "snp30"

[[4]]
 [1] "snp31" "snp32" "snp33" "snp34" "snp35" "snp36" "snp37" "snp38" "snp39"
[10] "snp40"

[[5]]
 [1] "snp41" "snp42" "snp43" "snp44" "snp45" "snp46" "snp47" "snp48" "snp49"
[10] "snp50"

[[6]]
 [1] "snp51" "snp52" "snp53" "snp54" "snp55" "snp56" "snp57" "snp58" "snp59"
[10] "snp60"

[[7]]
 [1] "snp61" "snp62" "snp63" "snp64" "snp65" "snp66" "snp67" "snp68" "snp69"
[10] "snp70"

[[8]]
 [1] "snp71" "snp72" "snp73" "snp74" "snp75" "snp76" "snp77" "snp78" "snp79"
[10] "snp80"

[[9]]
[1] "snp81" "snp82" "snp83" "snp84" "snp85" "snp86" "snp87" "snp88" "snp89"

[[10]]
[1] "snp90" "snp91" "snp92" "snp93" "snp94" "snp95" "snp96" "snp97" "snp98"

batch documentation built on April 17, 2018, 1:04 a.m.

Related to msplit in batch...