# Export dataset =============================================================
#' @rdname Menu-winow-functions
#' @export
#' @keywords internal
window_export_as_textfile <- function() {
function_not_implemented()
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' @rdname Menu-winow-functions
#' @export
#' @keywords internal
window_export_as_rds <- function() {
file_name <- ""
while (TRUE) {
break_cycle <- "yes"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
file_name <- tclvalue(tkgetSaveFile(
initialfile =
if (nchar(trimws(file_name)) > 0) {
extract_filename(file_name)
} else {
activeDataSet()
},
filetypes = "{ {Rds file} {.Rds .RDS .rds} } { {All Files} * }"))
# If canceled
if (nchar(trimws(file_name)) == 0) {
Message("Operation canceled, object was not saved.",
type = "warning")
return()
}
# Add extension if missing
if (!grepl("\\.[Rr][Dd][Ss]$", file_name)) {
# Add extension
file_name <- paste0(file_name, ".Rds")
# Check if a file with the same name exists
if (file.exists(file_name))
break_cycle <- tclvalue(Rcmdr::checkReplace(
glue::glue('"{file_name}"'), type = "File"))
}
# Exit the cycle, if everything is selected correctly
if (break_cycle == "yes") {
break
}
}
# Change these lines: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make_relative = TRUE
if (make_relative) {
file_name <- make_relative_path(file_name)
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
command <- glue::glue('saveRDS({activeDataSet()}, file = "{file_name}")')
doItAndPrint(command)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
window_export_as_excel <- function() {
function_not_implemented()
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.