#' To view a data.frame / data.table in LibreOffice Calc
#'
#' Take a data.frame, save it to a temporary file and open it with the
#' spreadsheet viewer of the OS.
#' Requires the package 'openxlsx' to work properly.
#' @param data the data.frame (or data.table)
#' @importFrom openxlsx write.xlsx
#' @export
view <- function(data) {
open_command <- switch(Sys.info()[['sysname']],
Windows= 'open',
Linux = 'xdg-open',
Darwin = 'open')
temp_file <- paste0(tempfile(), '.xlsx')
data <- as.data.frame(data)
write.xlsx(data, file = temp_file)
invisible(system(paste(open_command, temp_file),
ignore.stdout = TRUE, ignore.stderr = TRUE))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.