#' Image Move files
#'
#' Moves files into directories previously created with k_imgDirSetup
#'
#' @param directory Parent directory of label folders
#' @param files filenames of files to be moved
#' @param labels Labels of the files to be moved into appropriate folder. Labels should match folder names
#' @param train_id binary indicator saying whether the datapoint is training or testing (Train == 1)
#' @param delete Logical saying whether or not to deleter the file after copy.
#' @return Returns NULL
#' @export
k_imgMoveFiles <- function(directory, files, labels, train_id, delete = FALSE){
for (i in 1:length(files)) {
if (file.copy(from = paste0(directory, files[i]),
to = paste0(
directory,
ifelse(as.numeric(train_id[i]) == 1,
"train/",
"test/"),
labels[i], "/", files[i]
),
overwrite = TRUE)) {
if (delete) unlink(paste0(directory, files[i])) # Deletes file if copy was successful & delete == false
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.