View source: R/balanced_data.R
| balanced.train.and.test.from.vector | R Documentation | 
Get a balanced test and train dataset
balanced.train.and.test.from.vector(dat, train.perc = 0.9, join.all = TRUE)
dat | 
 vector of different types in data  | 
train.perc | 
 percentage of dataset to be training set  | 
join.all | 
 join all index in the end in two vectors (train and test vectors)  | 
train and test index vectors (two lists if 'join.all = FALSE', two vectors otherwise)
set.seed(1985) set1 <- rbinom(20, prob = 3/20, size = 1) == 1 balanced.train.and.test.from.vector(set1, train.perc = .9) #### set1 <- c(TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE, TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE) set2 <- !set1 balanced.train.and.test.from.vector(c(set1, set2), train.perc = .9) balanced.train.and.test.from.vector(c(set1, set2), train.perc = .9, join.all = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.