Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export("main_footer<-")
export("main_title<-")
export("mf_aligns<-")
export("mf_cinfo<-")
export("mf_col_widths<-")
export("mf_colgap<-")
export("mf_display<-")
export("mf_fontspec<-")
Expand Down Expand Up @@ -59,6 +60,7 @@ export(make_row_df)
export(matrix_form)
export(mf_aligns)
export(mf_cinfo)
export(mf_col_widths)
export(mf_colgap)
export(mf_display)
export(mf_fontspec)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## formatters 0.5.12.9002

* Export `mf_col_widths` accessor (`getter` and `setter`).

## formatters 0.5.12
* Added `"default"` format label which behaves like `"xx"` in `format_value` but indicates formatting behavior can be inherited from parent structures in upstream code.
* `round_type = "sas"` no longer displays a negative sign when negative values are rounded to zero.
Expand Down
4 changes: 4 additions & 0 deletions R/matrix_form.R
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,14 @@ mf_col_paths <- function(mf) {
}
}

#' @export
#' @rdname mpf_accessors
mf_col_widths <- function(mf) {
mf$col_widths
}

#' @export
#' @rdname mpf_accessors
`mf_col_widths<-` <- function(mf, value) {
if (!is.null(value) && length(value) != NCOL(mf_strings(mf))) {
stop(
Expand Down
6 changes: 6 additions & 0 deletions man/mpf_accessors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/testthat/test-mpf_accessors.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
test_that("mf_col_widths getter and setter are available and work", {
mf <- basic_matrix_form(mtcars)

# getter returns numeric vector
cw <- mf_col_widths(mf)
expect_true(is.numeric(cw))

# setter updates widths
new <- rep(10L, NCOL(mf_strings(mf)))
mf_col_widths(mf) <- new
expect_equal(mf_col_widths(mf), new)
})
Loading