Skip to content

Commit

Permalink
Merge pull request #281 from metrumresearchgroup/release/0.5.0
Browse files Browse the repository at this point in the history
Release/0.5.0
  • Loading branch information
kylebaron authored May 13, 2022
2 parents cb6ae78 + d0bd99f commit f3623bd
Show file tree
Hide file tree
Showing 73 changed files with 2,939 additions and 381 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
\.github
\.drone\.jsonnet
^data-raw$

tests/testthat/image/build
tests/testthat/image/*\.html

inst/demo-longtable\.log
inst/demo-longtable\.tex
inst/demo-pmtable\.log
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
tests/testthat/validate/validate.log

tests/testthat/image/build
tests/testthat/image/*.html

inst/demo-longtable.log
inst/demo-longtable.tex
inst/demo-pmtable.log
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pmtables
Type: Package
Title: Tables for Pharmacometrics
Version: 0.4.1
Version: 0.5.0
Authors@R:
c(
person(given = "Kyle",
Expand Down Expand Up @@ -32,7 +32,7 @@ License: GPL (>=2)
Imports: purrr, dplyr (>= 1.0.0), forcats, tidyr, rlang, glue, tibble,
assertthat, tidyselect, stringr, knitr, rmarkdown
Depends: R (>= 3.5.0)
Suggests: testthat, yaml, fs, texPreview
Suggests: testthat, yaml, fs, texPreview, magick, pdftools
Encoding: UTF-8
Language: en-US
LazyData: true
Expand All @@ -52,6 +52,7 @@ Collate:
'demographics-table.R'
'discrete_table.R'
'knit-dependencies.R'
'preview-standalone.R'
'preview.R'
'summarize-cat-chunk.R'
'table-align.R'
Expand Down
20 changes: 20 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ S3method(new_names,rowpanel)
S3method(print,digits)
S3method(print,stable_data)
S3method(print,stobject)
S3method(st_as_image,pmtable)
S3method(st_as_image,stable)
S3method(st_as_image,stobject)
S3method(st_control,default)
S3method(st_control,stobject)
S3method(st_new,data.frame)
S3method(st_new,pmtable)
S3method(st_wrap,default)
S3method(st_wrap,stable_long)
S3method(stable,data.frame)
Expand Down Expand Up @@ -77,11 +82,16 @@ export(rowpanel)
export(sig)
export(st2article)
export(st2doc)
export(st2pdf)
export(st2png)
export(st2report)
export(st2viewer)
export(st_align)
export(st_args)
export(st_as_image)
export(st_asis)
export(st_aspdf)
export(st_aspng)
export(st_blank)
export(st_bold)
export(st_center)
Expand All @@ -93,6 +103,7 @@ export(st_drop)
export(st_edit)
export(st_files)
export(st_hline)
export(st_image_show)
export(st_it)
export(st_knit_deps)
export(st_latex)
Expand All @@ -102,6 +113,12 @@ export(st_mutate)
export(st_new)
export(st_noteconf)
export(st_notes)
export(st_notes_app)
export(st_notes_conf)
export(st_notes_detach)
export(st_notes_rm)
export(st_notes_str)
export(st_notes_sub)
export(st_panel)
export(st_preview)
export(st_rename)
Expand Down Expand Up @@ -135,6 +152,7 @@ export(triage_data)
export(yaml_as_df)
importFrom(assertthat,assert_that)
importFrom(assertthat,validate_that)
importFrom(dplyr,across)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
Expand Down Expand Up @@ -203,6 +221,7 @@ importFrom(stringr,str_split)
importFrom(tibble,as_tibble)
importFrom(tibble,is_tibble)
importFrom(tibble,tibble)
importFrom(tidyr,complete)
importFrom(tidyr,fill)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
Expand All @@ -213,6 +232,7 @@ importFrom(tidyselect,all_of)
importFrom(tidyselect,contains)
importFrom(tidyselect,eval_rename)
importFrom(tidyselect,eval_select)
importFrom(tools,file_ext)
importFrom(utils,capture.output)
importFrom(utils,packageVersion)
importFrom(utils,str)
34 changes: 34 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# pmtables 0.5.0

- New functions `st_as_image()`, `st2pdf()`, and `st2png()` to render tables with
TeX to either `pdf` or `png` format; image files may be kept on disk
or read back for display while knitting; `pdflatex` system dependency for
`pdf` images and `latex` + `dvipng` for `png` images; additional Suggested
packages include `magick` and `pdftools` (#277, #278).

- `sig()` now returns character when integer type is passed (#272).

- `st_new()` is now generic with dispatch for `data.frame` and objects with
class `pmtable`; most pipeline functions can now be used to customize
tables coming from `pt_cat_*`, `pt_cont_*`, `pt_demographics()` and
`pt_data_inventory()` (#274).

- New functions `st_notes_detach()`, `st_notes_rm()`, `st_notes_app()`,
`st_notes_str()`, `st_notes_sub()` and `st_notes_conf()` to help working
with table notes in a pipe context (#274).

- `st_span()` and `st_span_split()` accept `align` argument to push column
spanner titles to the left, right or center (default); the argument eventually
gets passed to `colgroup()` (#261).

- `pt_cat_wide()`, `pt_cat_long()` and `pt_demographics()` gain argument
`denom` to alter the denominator when calculating percents for categorical
data summaries (#268).

- `pt_cat_wide()` gains argument `complete` to display missing levels of
`by` and `panel` (#268).

- Put stories in yaml format; add script to build validation docs from the
yaml file (#269, #270).


# pmtables 0.4.1

- `colgroup()` (and `st_span()`) gains an `align` argument to position
Expand Down
4 changes: 3 additions & 1 deletion R/AAAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#' @importFrom dplyr mutate bind_rows select ungroup summarise left_join
#' @importFrom dplyr group_modify rename count vars group_by n first last
#' @importFrom dplyr case_when filter arrange group_vars distinct bind_cols
#' @importFrom dplyr groups slice everything mutate_at
#' @importFrom dplyr groups slice everything mutate_at across
#' @importFrom purrr map_dfr walk partial map map_chr modify flatten_chr imap
#' @importFrom purrr flatten_int map_lgl modify_if map_int map2 keep flatten
#' @importFrom tidyr pivot_wider pivot_longer replace_na fill separate unite
#' @importFrom tidyr complete
#' @importFrom forcats fct_inorder
#' @importFrom rlang sym syms quo_get_expr as_string := .data .env is_empty
#' @importFrom rlang enquo enquos is_named is_atomic flatten_if have_name
Expand All @@ -15,6 +16,7 @@
#' @importFrom stats median rnorm sd na.omit setNames
#' @importFrom utils capture.output packageVersion str
#' @importFrom stringr fixed str_split str_count str_detect str_replace
#' @importFrom tools file_ext
#'
#' @include summary-functions.R
#' @include utils.R
Expand Down
4 changes: 2 additions & 2 deletions R/continuous_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ pt_cont_wide <- function(data, cols,

has_by <- !missing(by)

tst <- fun(rnorm(10))
assert_that(identical(names(tst),"summary"))
tst <- fun(c(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7))
assert_that(identical(names(tst), "summary"))

cols <- new_names(cols,table)
by <- new_names(by,table)
Expand Down
15 changes: 9 additions & 6 deletions R/demographics-table.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ dem_cont_fun <- function(value = seq(1,5), name = "", ..., fmt = sig,
#'
#' This function makes a single table from both continuous and categorical data.
#'
#' @inheritParams pt_cont_long
#' @inheritParams cat_data
#' @param data the data frame to summarize; the user should filter or subset
#' so that data contains exactly the records to be summarized; pmtables will not
#' add or remove rows prior to summarizing data
Expand Down Expand Up @@ -109,8 +111,6 @@ dem_cont_fun <- function(value = seq(1,5), name = "", ..., fmt = sig,
#' column with non-repeating names cleared and separated with `hline` (see
#' examples).
#'
#' @inheritParams pt_cont_long
#'
#' @details
#' When a continuous data summary function (`fun`) is passed, the user should
#' also pass a set of notes that explain the summary statistics produced
Expand Down Expand Up @@ -183,10 +183,11 @@ pt_demographics <- function(data, cols_cont, cols_cat,
stat_name = "Statistic",
stat_width = 2,
summarize_all = TRUE,
all_name = "All data",
all_name = "Summary",
fun = dem_cont_fun,
notes = pt_demographics_notes(),
paneled = TRUE) {
paneled = TRUE,
denom = c("group", "total")) {

summarize_all <- isTRUE(summarize_all)
summarize_span <- !is.null(span)
Expand Down Expand Up @@ -242,14 +243,16 @@ pt_demographics <- function(data, cols_cont, cols_cat,
data,
cols = all_of(cols_cat),
span = span,
summarize = "top"
summarize = "top",
denom = denom
)
}
if(summarize_all) {
cat_table_all0 <- pt_cat_long(
data,
cols = all_of(cols_cat),
summarize = "top"
summarize = "top",
denom = denom
)
cat_table_all <- rename(cat_table_all0[["data"]], value = "Summary")
}
Expand Down
Loading

0 comments on commit f3623bd

Please sign in to comment.