View source: R/data_converters.R
combined_file_system | R Documentation |
This function reorganises files that have been split into train and test directories using train_test_filesystem() back into a single directory. This is a convenience function to reverse the effects of train_test_filesystem().
combined_file_system(
path_to_folders,
file_ext,
train_folder = "train",
test_folder = "test",
overwrite = FALSE
)
path_to_folders |
path containing test and train folders; files will be moved here |
file_ext |
file extension to filter |
train_folder |
train folder subdirectory name |
test_folder |
test folder subdirectory name |
overwrite |
force overwrite of files that already exist |
Logical vector, indicated success or failure for each file
set.seed(123)
# create 10 random DNA files
tmp_dir <- tempdir()
# remove any existing .fna files
file.remove(
list.files(tmp_dir, pattern = "*.fna", full.names = TRUE)
)
for (i in 1:10) {
writeLines(paste0(">", i, "\n", paste0(sample(c("A", "T", "C", "G"),
100, replace = TRUE), collapse = "")), file.path(tmp_dir, paste0(i, ".fna")))
}
# split files into train and test directories
paths <- train_test_filesystem(tmp_dir,
file_ext = "fna",
split = 0.8,
shuffle = TRUE,
overwrite = TRUE)
# combine files back into a single directory
combined_file_system(tmp_dir, "fna")
list.files(tmp_dir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.