#' Create a "FileList" for an RQDA Project
#'
#' In the RQDA package, there is a notion of a FileList, which is an R list in
#' which each element is a character vector of length 1 containing the content
#' of a text file and the \code{names} of the list are the filenames.
#'
#' @param files A character vector with the filepaths.
#'
#' @details The \code{files} argument can be generated by \code{read_transcript}.
#' The approved format is plain text, but it may work for other text formats.
#'
#' @note For this function to work properly, the target RQDA project has to be
#' open i.e. activated with \code{library(RQDA)} or \code{RQDA()} as the
#' case may be. Future version of this function may automate this process.
#'
#'
#' @export
make_FileList <- function(files) {
txtrgx <- "\\.txt$"
## TODO: Either terminate when non-text file is passed OR automatically select
## valid file formats and issue a warning in each instance.
contentlist <- lapply(files, function(f) {
if (!file.exists(f))
stop("File ", basename(f), " was not found")
txt <- readLines(f)
paste(txt, collapse = '\n')
})
names(contentlist) <- sub(txtrgx, "", basename(files))
contentlist
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.