R/load_project_log_from_rdata.R

Defines functions load_project_log_from_rdata

Documented in load_project_log_from_rdata

#'Loads PROJECT_LOG R object
#'
#'This function loads the PROJECT_LOG from the PROJECT_LOG.RData file in the working directory. If the PROJECT_LOG.RData file does not exist, a blank one will be created, but will be populated using the update_project_log() function.
#'@param dirs_to_log character vector of the names of the directories that will be tracked for logging
#'@importFrom mirroR get_timestamp
#'@export
#'

load_project_log_from_rdata <-
        function(dirs_to_log) {
                if (!(file.exists("PROJECT_LOG.RData"))) {
                        list_names <- c("CURRENT", dirs_to_log)
                        x <- list()
                        for (i in 1:length(list_names)) {
                                x[[i]] <- list(create_log_dataframe())
                                names(x[[i]]) <- mirroR::get_timestamp()
                        }
                        names(x) <- list_names
                        x[["CURRENT"]] <- list()
                        base::assign("PROJECT_LOG", x, envir = base::globalenv())
                        base::saveRDS(x, "PROJECT_LOG.RData")
                } else {
                        x <- base::readRDS("PROJECT_LOG.RData")
                        base::assign("PROJECT_LOG", x, envir = base::globalenv())
                }
        }
patelm9/projectloggeR documentation built on Nov. 4, 2019, 11:21 p.m.