View source: R/add_labelled_sheet.R
add_labelled_sheet | R Documentation |
Row 1 contains variable labels; row 2 contains variable names, freeze panes, and filters. Header styling is applied. You can add additional styling options to sheet with the openxlsx::add functions after executed.
add_labelled_sheet(data, sheet_name = NULL, wrkbk, start_row = 1L)
data |
labelled data to add to sheet |
sheet_name |
optional sheet name; if none provided, sheet will be assigned name of input data set |
wrkbk |
expects a workbook object created from |
start_row |
integer row position where the labels must be placed, |
a workbook object
## Not run:
library(openxlsx)
library(croquet)
options("openxlsx.dateFormat" = "yyyy-mm-dd")
# example 1: single data frame ----
dat1 <- tibble::tibble(
var_1 = 1:3,
var_2 = LETTERS[1:3],
var_3 = Sys.Date() - 0:2
) %>%
labelled::set_variable_labels(
var_1 = "Variable 1 (numeric)",
var_2 = "Variable 2 (character)",
var_3 = "Variable 3 (date)"
)
wb <- createWorkbook()
add_labelled_sheet(dat1)
add_labelled_sheet(dat1, sheet_name = "example sheet")
saveWorkbook(wb, "checkwb.xlsx")
# example 2: list of data frames ----
dat2 <- tibble::tibble(
var_1 = 4:6,
var_2 = LETTERS[4:6],
var_3 = Sys.Date() - 0:2
) %>%
labelled::set_variable_labels(
var_1 = "Variable 1 (numeric)",
var_2 = "Variable 2 (character)",
var_3 = "Variable 3 (date)"
)
out <- tibble::lst(dat1, dat2)
wb <- createWorkbook()
add_labelled_sheet(out)
saveWorkbook(wb, "checkwb.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.