diff --git a/DESCRIPTION b/DESCRIPTION index 2b01982..ac2ab2f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,7 +15,8 @@ Imports: openxlsx, purrr, rlang, - stringr + stringr, + tibble Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index ad9b64e..a2c5956 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,12 +10,15 @@ export(add_notes_sheet) export(add_sheet_to_metadata) export(create_metadata) export(create_table_layout) +export(create_template_output) export(format_columns) export(format_rows) export(generate_table_metadata) export(make_contents_table) export(make_output_tables) export(negative_to_c) +export(save_output_tables) +export(table_list_to_tibble) export(tweak_formatting) importFrom(magrittr,"%>%") importFrom(rlang,.data) diff --git a/R/build_metadata.R b/R/build_metadata.R index e8b21cd..e4df7a0 100644 --- a/R/build_metadata.R +++ b/R/build_metadata.R @@ -1,7 +1,7 @@ #' Initialise Metadata Object #' #' @description Creates an empty metadata object which can be added to with -#' `r xlsss::add_sheet_to_metadata` +#' `xlsss::add_sheet_to_metadata` #' @export create_metadata <- function(){ @@ -42,7 +42,7 @@ add_sheet_to_metadata <- function(metadata, #' Combine Metadata and Tables to Create Layout #' #' Takes a metadata object and adds specified table_data to create a table layout to -#' be passed to `r xlsss::make_output_tables` +#' be passed to `xlsss::make_output_tables` #' @param metadata Metadata object #' @param table_data Tibble of tables. Must include columns: name, table and title. #' `name` column must match the table names specified in the metadata object. @@ -126,7 +126,7 @@ generate_table_metadata <- function(table_names, #' Convert List of Tables to table_data #' #' @description Helper function for quickly turning named list of tables into a -#' table_data object for use in the `r xlsss::create_table_layout` function. +#' table_data object for use in the `xlsss::create_table_layout` function. #' @param table_list List of tables to be converted to table_data #' @export table_list_to_tibble <- function(table_list){ diff --git a/R/export_tables.R b/R/export_tables.R index bea6b9d..24ddc28 100644 --- a/R/export_tables.R +++ b/R/export_tables.R @@ -552,7 +552,7 @@ make_output_tables <- function(metadata, notes_list, contents_title) { - if(!is_tibble(table_data)){ + if(!tibble::is_tibble(table_data)){ table_data <- table_list_to_tibble(table_data)} table_layout <- create_table_layout(metadata, table_data) diff --git a/man/create_metadata.Rd b/man/create_metadata.Rd index 59401cc..7ca1349 100644 --- a/man/create_metadata.Rd +++ b/man/create_metadata.Rd @@ -8,5 +8,5 @@ create_metadata() } \description{ Creates an empty metadata object which can be added to with -\verb{r xlsss::add_sheet_to_metadata} +\code{xlsss::add_sheet_to_metadata} } diff --git a/man/create_table_layout.Rd b/man/create_table_layout.Rd index 611ae92..dac7940 100644 --- a/man/create_table_layout.Rd +++ b/man/create_table_layout.Rd @@ -13,9 +13,9 @@ create_table_layout(metadata, table_data) \code{name} column must match the table names specified in the metadata object. \code{table} column contains the tables to be outputted to excel \code{title} column is only used where more than one table is included on a sheet -and is the sub title to be printed above the table.} +and is the subtitle to be printed above the table.} } \description{ Takes a metadata object and adds specified table_data to create a table layout to -be passed to \verb{r xlsss::make_output_tables} +be passed to \code{xlsss::make_output_tables} } diff --git a/man/create_template_output.Rd b/man/create_template_output.Rd new file mode 100644 index 0000000..a27eca9 --- /dev/null +++ b/man/create_template_output.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/create_template.R +\name{create_template_output} +\alias{create_template_output} +\title{Create Template Script to Output Tables} +\usage{ +create_template_output(filename = "template") +} +\arguments{ +\item{filename}{File to output template script to} +} +\description{ +Create Template Script to Output Tables +} diff --git a/man/make_output_tables.Rd b/man/make_output_tables.Rd index 93f87d1..e036967 100644 --- a/man/make_output_tables.Rd +++ b/man/make_output_tables.Rd @@ -4,16 +4,20 @@ \alias{make_output_tables} \title{Create excel tables} \usage{ -make_output_tables(table_layout, notes_list, contents_title, workbook_filename) +make_output_tables(metadata, table_data, notes_list, contents_title) } \arguments{ -\item{table_layout}{Table layout object created by metadata functions} +\item{metadata}{metadata object created by metadata functions} + +\item{table_data}{Tibble of tables. Must include columns: name, table and title. +\code{name} column must match the table names specified in the metadata object. +\code{table} column contains the tables to be outputted to excel +\code{title} column is only used where more than one table is included on a sheet +and is the subtitle to be printed above the table.} \item{notes_list}{List of notes in publication} \item{contents_title}{Title of contents page} - -\item{workbook_filename}{Filename to export workbook to} } \description{ Create excel tables diff --git a/man/save_output_tables.Rd b/man/save_output_tables.Rd new file mode 100644 index 0000000..4654044 --- /dev/null +++ b/man/save_output_tables.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/export_tables.R +\name{save_output_tables} +\alias{save_output_tables} +\title{Create and save excel tables} +\usage{ +save_output_tables( + metadata, + table_data, + notes_list, + contents_title, + workbook_filename +) +} +\arguments{ +\item{metadata}{metadata object created by metadata functions} + +\item{table_data}{Tibble of tables. Must include columns: name, table and title. +\code{name} column must match the table names specified in the metadata object. +\code{table} column contains the tables to be outputted to excel +\code{title} column is only used where more than one table is included on a sheet +and is the subtitle to be printed above the table.} + +\item{notes_list}{List of notes in publication} + +\item{contents_title}{Title of contents page} + +\item{workbook_filename}{Filename to export workbook to} +} +\description{ +Create and save excel tables +} diff --git a/man/table_list_to_tibble.Rd b/man/table_list_to_tibble.Rd index a7ac372..d2457b6 100644 --- a/man/table_list_to_tibble.Rd +++ b/man/table_list_to_tibble.Rd @@ -11,5 +11,5 @@ table_list_to_tibble(table_list) } \description{ Helper function for quickly turning named list of tables into a -table_data object for use in the \verb{r xlsss::create_table_layout} function. +table_data object for use in the \code{xlsss::create_table_layout} function. }