You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
write_chronicle <- function(.c, path, row.names = FALSE, sep = ",", ...){
stopifnot("Only provide one path" = {length(path) == 1})
value <- chronicler::pick(.c, "value")
stopifnot("Value must be of class data.frame!" = is.data.frame(value))
ext <- stringr::str_extract(path,
"\\.([0-9a-z]+)(?=[?#])|(\\.)(?:[\\w]+)$")
stopifnot("write_chronicle() can only save data as either .csv or .xlsx. Change the extension of the output." = (any(c(".csv", ".xlsx") %in% ext)))
log <- chronicler::read_log(.c)
if(ext == ".csv"){
logcsv <- c(paste0("This first ", length(log) + 2, " lines of this .csv file constitute a log."),
paste0("Skip the first ", length(log) + 2, " lines to read in the data."),
log)
write(logcsv, file = path)
suppressWarnings(
write.table(value, file = path, sep = sep, append = TRUE, row.names = row.names, ...)
)
} else {
logxlsx <- c("This sheet contains a log of the operations used to create the dataset in the 'value' sheet.",
log)
xlsx_output <- list("value" = value,
"log" = logxlsx)
openxlsx::write.xlsx(xlsx_output, file = path)
}
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: