NEWS.md
proc_freq gains new argument count_format_fun to let control the function that format the count values.0.9.8.as_raster(), lollipop() and set_formatter_type().'' with footnotes. Users should use add_footer_lines() instead.tab_settings() is now using j argument as expected (#635)set_table_properties() with layout that defaults to “fixed”.delete_column() (#676)fmt_signif_after_zeros() fixed issue with 0 roundingproc_freq supports now non syntactically namesfix_border_issues function is now useless for users, as it is now called automatically before printing.flextable_to_rmd() issue with images in pdf (issue #651)flextable_to_rmd() issue with local chunk eval option (issue #631)proc_freq can now display only the table percentages without the count using include.table_count = FALSE.pagedown >= 0.20.2
headers_flextable_at_bkm() and footers_flextable_at_bkm() are defunct.flextable_to_rmd() is now using knit_child() for safer usage from for loops or if statements.save_as_image() and ph_with.flextable().as_raster() since gen_grob() is easier to use and render nicer.align(), the default argument value for align is now "left", rather than c("left", "center", "right", "justify"). This returns the default value to how it was in older versions of {flextable}.align(), use of the old default align argument could cause an error if the number of columns being adjusted was not a multiple of 4.align had to be a single value, when it could actually accept multiple values. This is why a default value of c("left", "center", "right", "justify"), was problematic. This documentation has now been updated and new examples included in the documentation.align argument will now apply left alignment to all columns in the body.path argument now has a signature of part = c("body", "header", "footer", "all"), but because only a single value can be selected, it will pick "body" by default, as before.lollipop() since it produces (ugly) results that can be replaced by nice results with gg_chunk() or grid_chunk().as_image() when the table contains no text.align() issue with recycling and update documentation that was wrong about argument align that is vectorized over columns.tab_settings() to set tabulation marks configuration for Word and RTF. It works with officer::fp_tabs().fmt_signif_after_zero() to round significant figures after zeros.summarizor() don’t stop anymore if table only contain discrete columns.as_flextable.data.frame() supports ‘data.table’footnote() handle undefined ref_symbols argumentdelete_rows() does not delete rows if the row selection is emptygen_grob() alignments when wrapping textgen_grob() when cells are vertically mergedset_caption() can have no bookmark and have autonumber used together.tabcolsep is now set to 2.set_formatter_type().fmt_2stats() so that it uses global flextable settings, i.e. digits, etc.set_table_properties(opts_pdf = list(footer_repeat = TRUE)).as_chunk()
ph_with.flextable() formats widths and heights correctly.delete_columns() and delete_rows() to let users delete rows or columns.save_as_image() now supports svg export with ‘svglite’.summarizor() function has been enhanced to offer three new options:by argument meaning ‘no grouping,’as_flextable.data.frame() always shows the number of rows even if less than 10 (because I need it!).as_flextable.lm(), as_flextable.gam(), as_flextable.glm(), as_flextable.merMod() and as_flextable.htest() now respect the global value of getOption("show.signif.stars").add.random in as_flextable.merMod() to let add or not random effects in the final table.max_iter of function fit_to_width is not ignored anymore.dim_pretty() returns correct numbers when not ‘inches’as_flextable.table() now propagates ... as expectedset_table_properties(opts_pdf = list(caption_repeat = FALSE)).as_flextable() now works on tabular objects and R < 4.1.to_html(type = "img") now use the correct width and height1.4.as_flextable.tabular() now generate tabulated content only if the sub group contains more than a single row. When possible, row titles are tabulated.footers_flextable_at_bkm and headers_flextable_at_bkm are deprecated. Instead, we recommend using the prop_section() and block_list() functions from the officer package as alternative solutions. These functions provide more reliable and flexible options for managing footers and headers.keepnext and ft.keepnext are defunct, they are replaced by function paginate() that enable nice pagination of tables across pages or keep_with_next() to get total control over rows pagination.set_flextable_defaults() gains parameter pct_digits (number of digits for percentages) that will be used in relevant functions (only proc_freq() for now).as_flextable.table().fmt_dbl(), fmt_int() and fmt_pct().paginate()
type is now possible when using tabulator().save_as_html() ugly default title.set_header_labels() from a simple un-named vector.set_formatter() now accepts single function to be applied to all columns.gdtools::register_gfont().save_as_html(): use rmarkdown and add google fonts if possible (See gdtools::register_gfont()).In short:
tables::tabular(): “Computes a table of summary statistics, cross-classified by various variables”officer::rtf_add().tables::tabular() to flextable with new function as_flextable.tabular().to_html.flextable() to make easy embedding of flextable results in HTML (with ‘ggiraph’ for example).border.width (see ?set_flextable_defaults()) and set its default value to .75, this setting is used in theme functions. The old default value was hard coded to 1 and can be defined during the whole R session with set_flextable_defaults(border.width = 1).officer_url_encode() to encode URL in office files.knit_print.flextable() and related functions.headers_flextable_at_bkm() and footers_flextable_at_bkm()
0.8.4.body_add_flextable().expand_single in as_flextable.tabulator(). If FALSE, groups with only one row will not be expanded with a title row.labels of labelizor() now support functions in addition to named vectors.as.character() now returns the HTML string of the tableas_flextable for data.frame using df_printer() function implementation.expand_single in as_grouped_data(). If FALSE, groups with only one row will not be expanded with a title row.fmt_avg_dev(), fmt_header_n(), fmt_n_percent() and renaming of fmt_2stats() to fmt_summarizor() to help working with tabulator(). tabulator() has also new internal values that allow N=xxx notes and automatic labels.set_table_properties() is now the recommanded way to set arguments related to format options and alignment in a document. It is supposed to replace “knitr” chunk options ft.align, ft.split, ft.keepnext, ft.tabcolsep, ft.arraystretch, ft.latex.float, ft.shadow, fonts_ignore although they are all still supported. This allows less interaction with the ‘R Markdown’ or ‘Quarto’ eco-system and let to define it globally with set_flextable_defaults().set_table_properties() and providing a scroll value for argument opts_html: opts_html = list(scroll = list(height = "500px",freeze_first_column = TRUE)).grid_chunk() to let users add grid graphicsadd_header_row(), add_footer_row(), add_body_row(), add_header_lines() and add_footer_lines() now supports formatted paragraph made with as_paragraph().as_paragraph()
summarizor() can now be transformed directly as a flextable with method as_flextable().body_add_flextable()
prepend_chunks()
line_spacing() as it is expected to be a ratioft.keepnext now default to FALSE as lot of users had issues with this option.xtable_to_flextable() is removed (use as_flextable())gen_grob().labelizor() is a new function to help change text by labels.fp_par()) in captions with set_caption().as_paragraph()
set_table_properties() or setting values to knitr chunk options tab.alt.title and tab.alt.description.set_caption(). The alignment of the paragraph can be different from the alignment of the table with the argument align_with_table=FALSE.theme_apa (@rempsyc #426)as_flextable.tabulator() gains an argument spread_first_col to enable spreading of the first column of the table as a line separator.save_as_docx() to avoid Word confusionfortify_width() calculationas_flextable.tabulator() gained an argument label_rows used for labels to display in the first column names, i.e. the row column names.shift_table() to produce Shift Tables used used in clinical trial analysis ready to be used by tabulator().as_image() don’t need anymore parameters width and height if package ‘magick’ is available.plot.flextable now default to grid Graphics. It produce a plot object that can be used with packages ‘ggplot2’, ‘patchwork’ and ‘cowplot’. The raster version made with ‘webshot’ and ‘magick’ pachages is still available, use plot(..., method = "webshot").add_footer_lines() instead.as_flextable() has now methods for lm, glm, models from package ‘lme’ and ‘lme4’, htest (t.test, chisq.test, …), gam, kmeans and pam.use_model_printer() to set model automatic printing as a flextable in an R Markdown document.add_body_row() to add a row in the body part with eventually merged/spanned columns.tabulator_colnames() to get column names of a tabulator object.prepend_chunks() to prepend chunks of content in flextable cells as with as_paragraph() but without replacing the whole content.as_word_field() to let add ‘Word’ computed values into a flextable, as as_word_field(x = "Page") for a page number.separate_header() to Separate collapsed colnames into multiple rows.autofit() and dim_pretty() now support newlines.autofit() and dim_pretty() now have an argument hspans to help specify how horizontally spanned cells should affect the results.ft.latex.float, supported values are ‘none’ (the default value), ‘float’, ‘wrap-r’, ‘wrap-l’, ‘wrap-i’ and ‘wrap-o’.ft.htmlscroll = FALSE.tabulator() can display any columns before and after the columns of displayed aggregations.i, j and part at the end of the function arguments, after the ....supp_data in the result table of tabulator()
j and source when color is a function (in bg(), highlight() and color()) is now based on colnames to avoid mistake while mapping. #395append_chunks() to append chunks of content in flextable cells as with as_paragraph() but without replacing the whole content.tabulator() and its method as_flextable.tabulator() that help the creation of tables used in life science industry. It also comes with function summarizor() and sugar function fmt_2stats().empty_blanks() gained arguments width so that users can also set blank columns’ width.... to format() function when using colformat_num(). It makes possible to use arguments for format(), for example colformat_num(drop0trailing = TRUE).ft.keepnext and parameter keepnext to function body_add_flextable() that enable the Word option ‘keep rows together’, so that page break within a table is avoided when possible.add_latex_dep() to manually add flextable latex dependencies to the knitr session.<img> entries with invalid width attributes e.g. width=40\%.df_printer that can be used via the df_print option of R Markdown documents or by calling use_df_printer().tab.cap.fp_text to let format caption prefix in function opts_current_table().colformat_* and set_flextable_defaults.surround() to ease the highlighting of specific cells with borders.print(x, preview ="pdf").tab.topcaption that let modify the table caption position from “top” (TRUE) to “bottom” (FALSE).before() to ease addition of hline() before some values to match with.chunk_dataframe for those who want to create functions that work with as_paragraph.flextable-shadow-host.set_flextable_defaults now accept argument padding that set values for padding top, bottom, left and right.colorize, as_highlight
nrow_part and ncol_keys are now exportedcompose has a new argument use_dot to let use . and loop over columnsinit_flextable_defaults()
git diff
colformat_num calls the format function on the numeric values (integer and float) which are therefore displayed as in console R. This function is used during the creation of a flextable so that by default the content of the cells is the same as that displayed in console R.merge_v has a new argument combine to let use j columns be used as a single value (all values are pasted).add_body for adding rows into a flextable bodycolformat_image for images in flextableas_flextable for gam modelsset_flextable_defaults gained 4 new arguments post_process_pdf, post_process_html, post_process_docx and post_process_pptx to enable flextable post-treatments conditionned by the output format.fp_text_default and fp_border_default.\n and \t usage for pdfhighlight() for text highlighting colorset_flextable_defaults() to set some default formatting properties, i.e. default border color, font color, padding, decimal.mark …save_as_docx gained a new argument pr_section to define page layout with section properties, save_as_html can now output more than a single table.colformat_ functions now use default values and filter columns that are irrelevant (i.e. if colformat_num, only numeric values are formatted). Also, new colformat_ functions have been implemented (colformat_date, colformat_datetime and colformat_double).plot_chunk and gg_chunk to add miniplots or ggplots into a flextableph_with_flextable()
.
fix_border_issues is the last instruction of all theme functions so that borders are corrected if some cells have been merged.tab_props$cap has a value.encoding
line_spacing() (or with function style()).footnote is now able to add inline footnotesxtable_to_flextable())continuous_summary(): summarize continuous columns in a flextableautofit can now use only some parts of the tables. This allows for example to no longer have gigantic columns by not taking into account the “footer” part that is often composed of long texts.set_table_properties lets adapt flextable size as “100%”, “50%” of the available width for Word and HTML.bg() and color() now accept functions (i.e. scales::col_numeric())display().ph_with_flextable_at()
knit_to_wml() has new arguments align, split and tab.cap.style
htmltools_value() has a new argument ft.align
flextable_html_dependency to get flextable htmltools::htmlDependancy. This is necessary to output flextables in html R Markdown documents from loop or other nested operations.save_as_docx, save_as_pptx that lets users export flextable objects to PowerPoint or Word documents.hrule to control how row heights should be understood (at least, auto, exact)lollipop that lets users add mini lollipop chart to flextable (kindly provided by github.com/pteridin)proc_freq got a new argument weight to enable weighting of results.as_flextable.grouped_data() has now an argument hide_grouplabel to let not print the group names.webshot in function save_as_image or with chunk option webshot="webshot2".knit_to_wml to let display flextables from non top level calls inside R Markdown document.ph_location* usage and make placement into slides easier.fit_to_width to fit a flextable to a maximum widthset_caption can now be used with R Markdown for Word document and caption style can be defined with chunk option tab.cap.style.theme_alafoli() and theme_vader()
align_text_col() and align_nottext_col() to align columns by data typemerge_h_range() to merge a set of columns row by rowfix_border_issues() fix issues with borders when cells are mergedadd_header_row(), add_footer_row(), add_header_lines() and add_footer_lines() to add easily data in header or footer.as_flextable() to let develop new flextable functionsas_grouped_data() and its method as_flextable() to create row titles to separate data in a flextable.body_replace_flextable_at_bkm to replace a bookmarked paragraph by a flextable.colformat_* to make content formatting easier. It also deals with NA.format.flextable method so that users can create their components.ft.align to align tables in rmarkdown::word_document and ft.split to activate Word option ‘Allow row to break across pages’.display()
vline()
\n is now supported. Function autofit and dim_pretty do not support soft returns and may return wrong results (will be considered as "").border_outer()
hyperlink_text() to be used with display, font()
hline*() and vline*() and many new helper functions to be used instead of borders.xtable_to_flextable() that is returning a flextable from an xtable object.htmltools_value() is exported for shiny applications.ph_with_flextable_at to add a flextable at any position in a slide.merge_at is providing a general way of merging cells.theme_box()