diff --git a/NAMESPACE b/NAMESPACE index 7cd6213..d02f27d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,8 @@ export(col_borders) export(freq) export(generate_results) export(gentlg) +export(get_file_name) +export(insert_empty_rows) export(nested_freq) export(no_borders) export(replace_na_with_blank) diff --git a/NEWS.md b/NEWS.md index 3afdc82..2a61ca0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # tidytlg 0.11.0.9000 +- Exported functions `get_file_name()` and `insert_empty_rows()`. - Updated `gentlg_single()` to replace, in the first column of tables/listings headers, every leading whitespace with 90 twips (0.0625 inches) left-indentation RTF markup. # tidytlg 0.11.0 diff --git a/R/getFileName.R b/R/getFileName.R index 4d1678c..86b635e 100644 --- a/R/getFileName.R +++ b/R/getFileName.R @@ -5,10 +5,10 @@ #' #' @author Steven haesendonckx {shaesen2@@its.jnj.com} #' -#' @return The file path up untill the program's name. -#' @param file name of the file -#' -#' @noRd +#' @return The file path up until the program's name. +#' @export +#' @examples +#' get_file_name() get_file_name <- function() { ##### If run from MCD BATCH\ file_name <- get_file_name_batch(commandArgs(trailingOnly = FALSE)) diff --git a/R/insert_empty_rows.R b/R/insert_empty_rows.R index 036ef4b..2b4129c 100644 --- a/R/insert_empty_rows.R +++ b/R/insert_empty_rows.R @@ -2,19 +2,29 @@ #' #' @details #' `gentlg` allows for formatting the input table based on formatting columns -#' (see [gentlg()]). One of the formatting mechanisms is empty row insertion. This -#' function inserts the empty rows based on the `newrows` column in the data -#' frame. The new rows are inserted before the rows with value `1` in the +#' (see [gentlg()]). One of the formatting mechanisms is empty row insertion. +#' This function inserts the empty rows based on the `newrows` column in the +#' data frame. The new rows are inserted before the rows with value `1` in the #' `newrows` column. #' #' @param huxme `data.frame` The input data frame. +#' @param newrows `integer` A numeric vector specifying where the new rows +#' should be inserted. #' #' @return A data frame with added new empty rows. -#' @keywords internal +#' @export +#' +#' @examples +#' df <- iris[1:10, ] +#' df <- as.data.frame(apply(df, 2, as.character)) +#' df$newrows <- c(0, 1, 0, 1, 1, 0, 0, 0, 0, 0) +#' insert_empty_rows(df) insert_empty_rows <- function(huxme, newrows = huxme$newrows) { if (is.null(newrows)) { return(huxme) } + assertthat::assert_that(is.data.frame(huxme)) + assertthat::assert_that(is.numeric(newrows)) assertthat::assert_that(nrow(huxme) == length(newrows)) format_columns <- c("row_type", "anbr", "indentme", "roworder", "newrows") diff --git a/inst/WORDLIST b/inst/WORDLIST index 11d0577..5e6903d 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -14,6 +14,8 @@ Timepoint Vectorized envsetup funder +getFileName +haesendonckx hardcoded huxtable jnj diff --git a/man/get_file_name.Rd b/man/get_file_name.Rd new file mode 100644 index 0000000..f4e433e --- /dev/null +++ b/man/get_file_name.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getFileName.R +\name{get_file_name} +\alias{get_file_name} +\title{getFileName} +\usage{ +get_file_name() +} +\value{ +The file path up until the program's name. +} +\description{ +This function returns the file path up until the program's +name. +} +\examples{ +get_file_name() +} +\author{ +Steven haesendonckx {shaesen2@its.jnj.com} +} diff --git a/man/insert_empty_rows.Rd b/man/insert_empty_rows.Rd index d1a8d8e..05de292 100644 --- a/man/insert_empty_rows.Rd +++ b/man/insert_empty_rows.Rd @@ -8,6 +8,9 @@ insert_empty_rows(huxme, newrows = huxme$newrows) } \arguments{ \item{huxme}{\code{data.frame} The input data frame.} + +\item{newrows}{\code{integer} A numeric vector specifying where the new rows +should be inserted.} } \value{ A data frame with added new empty rows. @@ -17,9 +20,14 @@ Inserts empty rows into a data frame } \details{ \code{gentlg} allows for formatting the input table based on formatting columns -(see \code{\link[=gentlg]{gentlg()}}). One of the formatting mechanisms is empty row insertion. This -function inserts the empty rows based on the \code{newrows} column in the data -frame. The new rows are inserted before the rows with value \code{1} in the +(see \code{\link[=gentlg]{gentlg()}}). One of the formatting mechanisms is empty row insertion. +This function inserts the empty rows based on the \code{newrows} column in the +data frame. The new rows are inserted before the rows with value \code{1} in the \code{newrows} column. } -\keyword{internal} +\examples{ +df <- iris[1:10, ] +df <- as.data.frame(apply(df, 2, as.character)) +df$newrows <- c(0, 1, 0, 1, 1, 0, 0, 0, 0, 0) +insert_empty_rows(df) +}