flextable/0000755000176200001440000000000014515315543012226 5ustar liggesusersflextable/NAMESPACE0000644000176200001440000002202114515155156013444 0ustar liggesusers# Generated by roxygen2: do not edit by hand S3method(as_flextable,brmsfit) S3method(as_flextable,data.frame) S3method(as_flextable,gam) S3method(as_flextable,glm) S3method(as_flextable,glmmTMB) S3method(as_flextable,glmmadmb) S3method(as_flextable,gls) S3method(as_flextable,grouped_data) S3method(as_flextable,htest) S3method(as_flextable,kmeans) S3method(as_flextable,lm) S3method(as_flextable,lme) S3method(as_flextable,merMod) S3method(as_flextable,nlme) S3method(as_flextable,pam) S3method(as_flextable,summarizor) S3method(as_flextable,table) S3method(as_flextable,tabular) S3method(as_flextable,tabulator) S3method(as_flextable,xtable) S3method(dim,flextable) S3method(dim,flextableGrob) S3method(drawDetails,flextableHighlightedGrob) S3method(drawDetails,flextableRowPartGrob) S3method(knit_print,flextable) S3method(knit_print,run_reference) S3method(makeContext,flextableGrob) S3method(ph_with,flextable) S3method(plot,flextable) S3method(plot,flextableGrob) S3method(print,flextable) S3method(print,flextable_defaults) S3method(print,tabulator) S3method(rtf_add,flextable) S3method(summary,tabulator) S3method(to_html,flextable) S3method(to_rtf,flextable) S3method(to_wml,flextable) export(add_body) export(add_body_row) export(add_footer) export(add_footer_lines) export(add_footer_row) export(add_header) export(add_header_lines) export(add_header_row) export(add_latex_dep) export(align) export(align_nottext_col) export(align_text_col) export(append_chunks) export(as_b) export(as_bracket) export(as_chunk) export(as_equation) export(as_flextable) export(as_grouped_data) export(as_highlight) export(as_i) export(as_image) export(as_paragraph) export(as_raster) export(as_sub) export(as_sup) export(as_word_field) export(autofit) export(before) export(bg) export(body_add_flextable) export(body_replace_flextable_at_bkm) export(bold) export(border) export(border_inner) export(border_inner_h) export(border_inner_v) export(border_outer) export(border_remove) export(chunk_dataframe) export(colformat_char) export(colformat_date) export(colformat_datetime) export(colformat_double) export(colformat_image) export(colformat_int) export(colformat_lgl) export(colformat_num) export(color) export(colorize) export(compose) export(continuous_summary) export(delete_columns) export(delete_part) export(delete_rows) export(df_printer) export(dim_pretty) export(empty_blanks) export(fit_to_width) export(fix_border_issues) export(flextable) export(flextable_dim) export(flextable_html_dependency) export(flextable_to_rmd) export(fmt_2stats) export(fmt_avg_dev) export(fmt_dbl) export(fmt_header_n) export(fmt_int) export(fmt_n_percent) export(fmt_pct) export(fmt_summarizor) export(font) export(fontsize) export(footers_flextable_at_bkm) export(footnote) export(fp_border_default) export(fp_text_default) export(gen_grob) export(get_flextable_defaults) export(gg_chunk) export(grid_chunk) export(headers_flextable_at_bkm) export(height) export(height_all) export(highlight) export(hline) export(hline_bottom) export(hline_top) export(hrule) export(htmltools_value) export(hyperlink_text) export(init_flextable_defaults) export(italic) export(keep_with_next) export(labelizor) export(line_spacing) export(linerange) export(lollipop) export(merge_at) export(merge_h) export(merge_h_range) export(merge_none) export(merge_v) export(minibar) export(mk_par) export(ncol_keys) export(nrow_part) export(padding) export(paginate) export(plot_chunk) export(prepend_chunks) export(proc_freq) export(qflextable) export(regulartable) export(rotate) export(save_as_docx) export(save_as_html) export(save_as_image) export(save_as_pptx) export(save_as_rtf) export(separate_header) export(set_caption) export(set_flextable_defaults) export(set_footer_df) export(set_formatter) export(set_formatter_type) export(set_header_df) export(set_header_labels) export(set_table_properties) export(shift_table) export(style) export(summarizor) export(surround) export(tabulator) export(tabulator_colnames) export(theme_alafoli) export(theme_apa) export(theme_booktabs) export(theme_box) export(theme_tron) export(theme_tron_legacy) export(theme_vader) export(theme_vanilla) export(theme_zebra) export(use_df_printer) export(use_model_printer) export(valign) export(vline) export(vline_left) export(vline_right) export(void) export(width) import(data.table) importFrom(data.table,":=") importFrom(data.table,.GRP) importFrom(data.table,.N) importFrom(data.table,.SD) importFrom(data.table,as.data.table) importFrom(data.table,data.table) importFrom(data.table,dcast) importFrom(data.table,fcase) importFrom(data.table,fifelse) importFrom(data.table,first) importFrom(data.table,fsetdiff) importFrom(data.table,groupingsets) importFrom(data.table,is.data.table) importFrom(data.table,rbindlist) importFrom(data.table,rleid) importFrom(data.table,rleidv) importFrom(data.table,setDF) importFrom(data.table,setDT) importFrom(data.table,setcolorder) importFrom(data.table,setkeyv) importFrom(data.table,setnames) importFrom(data.table,setorderv) importFrom(data.table,shift) importFrom(data.table,tstrsplit) importFrom(gdtools,installed_gfonts) importFrom(gdtools,m_str_extents) importFrom(gdtools,str_metrics) importFrom(grDevices,as.raster) importFrom(grDevices,col2rgb) importFrom(grDevices,dev.off) importFrom(grDevices,is.raster) importFrom(grDevices,rgb) importFrom(graphics,boxplot) importFrom(graphics,par) importFrom(graphics,plot) importFrom(grid,convertHeight) importFrom(grid,convertWidth) importFrom(grid,drawDetails) importFrom(grid,gList) importFrom(grid,gTree) importFrom(grid,gpar) importFrom(grid,grid.draw) importFrom(grid,grid.layout) importFrom(grid,grid.newpage) importFrom(grid,grid.rect) importFrom(grid,grobDescent) importFrom(grid,grobHeight) importFrom(grid,grobWidth) importFrom(grid,is.grob) importFrom(grid,makeContext) importFrom(grid,popViewport) importFrom(grid,pushViewport) importFrom(grid,rasterGrob) importFrom(grid,rectGrob) importFrom(grid,segmentsGrob) importFrom(grid,setChildren) importFrom(grid,textGrob) importFrom(grid,unit) importFrom(grid,viewport) importFrom(grid,vpStack) importFrom(htmltools,HTML) importFrom(htmltools,attachDependencies) importFrom(htmltools,browsable) importFrom(htmltools,div) importFrom(htmltools,htmlDependency) importFrom(htmltools,htmlEscape) importFrom(htmltools,save_html) importFrom(htmltools,tagList) importFrom(htmltools,tags) importFrom(knitr,asis_output) importFrom(knitr,fig_path) importFrom(knitr,include_graphics) importFrom(knitr,is_html_output) importFrom(knitr,is_latex_output) importFrom(knitr,knit_meta_add) importFrom(knitr,knit_print) importFrom(knitr,opts_current) importFrom(knitr,opts_knit) importFrom(knitr,pandoc_to) importFrom(knitr,raw_block) importFrom(knitr,raw_html) importFrom(knitr,raw_latex) importFrom(officer,add_slide) importFrom(officer,body_add_par) importFrom(officer,body_add_xml) importFrom(officer,body_set_default_section) importFrom(officer,cursor_bookmark) importFrom(officer,fp_border) importFrom(officer,fp_cell) importFrom(officer,fp_par) importFrom(officer,fp_text) importFrom(officer,fp_text_lite) importFrom(officer,fpar) importFrom(officer,ftext) importFrom(officer,image_to_base64) importFrom(officer,officer_url_encode) importFrom(officer,opts_current_table) importFrom(officer,page_mar) importFrom(officer,page_size) importFrom(officer,ph_location_type) importFrom(officer,ph_with) importFrom(officer,prop_section) importFrom(officer,prop_table) importFrom(officer,read_docx) importFrom(officer,read_pptx) importFrom(officer,rtf_add) importFrom(officer,rtf_doc) importFrom(officer,run_autonum) importFrom(officer,run_bookmark) importFrom(officer,str_encode_to_rtf) importFrom(officer,table_colwidths) importFrom(officer,table_layout) importFrom(officer,table_width) importFrom(officer,to_html) importFrom(officer,to_rtf) importFrom(officer,to_wml) importFrom(ragg,agg_png) importFrom(rlang,call_args) importFrom(rlang,enquo) importFrom(rlang,enquos) importFrom(rlang,eval_tidy) importFrom(rlang,get_expr) importFrom(rlang,new_function) importFrom(rlang,pairlist2) importFrom(rlang,quo) importFrom(rlang,quo_name) importFrom(rlang,quo_text) importFrom(rlang,sym) importFrom(rmarkdown,html_document) importFrom(rmarkdown,latex_dependency) importFrom(rmarkdown,pandoc_available) importFrom(rmarkdown,pandoc_version) importFrom(rmarkdown,pdf_document) importFrom(rmarkdown,render) importFrom(stats,AIC) importFrom(stats,BIC) importFrom(stats,IQR) importFrom(stats,approx) importFrom(stats,as.formula) importFrom(stats,density) importFrom(stats,df.residual) importFrom(stats,logLik) importFrom(stats,mad) importFrom(stats,median) importFrom(stats,na.omit) importFrom(stats,naprint) importFrom(stats,nobs) importFrom(stats,quantile) importFrom(stats,reshape) importFrom(stats,runif) importFrom(stats,sd) importFrom(stats,setNames) importFrom(stats,terms) importFrom(stats,update) importFrom(utils,browseURL) importFrom(utils,compareVersion) importFrom(utils,getFromNamespace) importFrom(utils,head) importFrom(utils,modifyList) importFrom(utils,packageVersion) importFrom(utils,tail) importFrom(uuid,UUIDgenerate) importFrom(xml2,as_xml_document) importFrom(xml2,xml_find_first) importFrom(xml2,xml_parent) importFrom(xml2,xml_replace) flextable/README.md0000644000176200001440000000574614412125552013514 0ustar liggesusersflextable R package ================ [![R build status](https://github.com/davidgohel/flextable/workflows/R-CMD-check/badge.svg)](https://github.com/davidgohel/flextable/actions) [![version](https://www.r-pkg.org/badges/version/flextable)](https://CRAN.R-project.org/package=flextable) ![Active](https://www.repostatus.org/badges/latest/active.svg) The flextable package provides a framework for easily create tables for reporting and publications. Tables can be easily formatted with a set of verbs such as `bold()`, `color()`, they can receive a header of more than one line, cells can be merged or contain an image. The package make it possible to build any table for publication from a `data.frame` and provides sugar function `as_flextable()` to convert several R objects to a flextable, such as an object return from `table()` or a model. ``` r set_flextable_defaults( font.family = "Arial", font.size = 10, border.color = "gray") flextable(head(cars)) %>% bold(part = "header") %>% add_footer_lines("The 'cars' dataset") ggplot2::diamonds |> with(table(cut, color)) |> as_flextable() ``` Tables can be embedded within HTML, PDF, Word and PowerPoint documents from R Markdown documents and within RTF or Microsoft Word or PowerPoint documents with package officer. Tables can also be rendered as R plots or graphic files (png). flextable formats ``` r flextable(mtcars) %>% theme_vanilla() %>% save_as_docx(path = "mytable.docx") ``` A `flextable` object is a data.frame representation. An API is available to let R users create tables for reporting and control their formatting properties and their layout. The package provides functions that give control over: - header, body and footer content - text, paragraphs, cells and border formatting of any element - displayed values The package also offers a set of high-level functions that allow tabular reporting of statistical models and the creation of complex cross tabulations. ## Installation ``` r install.packages("flextable") ``` You can get the development version from GitHub: ``` r devtools::install_github("davidgohel/flextable") ``` ## Resources - User guide: - Manuals: - Gallery of examples: ### Getting help / questions If you have questions about how to use the package, visit Stackoverflow and use tags `flextable` and `r` [Stackoverflow link](https://stackoverflow.com/questions/tagged/flextable+r). You can also use to start a discussion. ### Bug reports When you file a [bug report](https://github.com/davidgohel/flextable/issues), please spend some time making it easy for us to reproduce. If you take the time to make the bug report consistent, it will be easier to fix. flextable/man/0000755000176200001440000000000014515155156013003 5ustar liggesusersflextable/man/footers_flextable_at_bkm.Rd0000644000176200001440000000136314432120335020306 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/body_add_flextable.R \name{footers_flextable_at_bkm} \alias{footers_flextable_at_bkm} \title{Add flextable at a bookmark location in document's footer} \usage{ footers_flextable_at_bkm(x, bookmark, value) } \arguments{ \item{x}{an rdocx object} \item{bookmark}{bookmark id} \item{value}{a flextable object} } \description{ replace in the footer of a document a paragraph containing a bookmark by a flextable. A bookmark will be considered as valid if enclosing words within a paragraph; i.e., a bookmark along two or more paragraphs is invalid, a bookmark set on a whole paragraph is also invalid, but bookmarking few words inside a paragraph is valid. } \keyword{internal} flextable/man/border_inner_v.Rd0000644000176200001440000000223214476430470016267 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{border_inner_v} \alias{border_inner_v} \title{Set vertical inner borders} \usage{ border_inner_v(x, border = NULL, part = "all") } \arguments{ \item{x}{a flextable object} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying a vertical border to inner content of one or all parts of a flextable. } \examples{ library(officer) std_border <- fp_border(color = "orange", width = 1) dat <- iris[c(1:5, 51:55, 101:105), ] ft <- flextable(dat) ft <- border_remove(x = ft) # add inner vertical borders ft <- border_inner_v(ft, border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/use_df_printer.Rd0000644000176200001440000000106014375473105016300 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/df_printer.R \name{use_df_printer} \alias{use_df_printer} \title{Set data.frame automatic printing as a flextable} \usage{ use_df_printer() } \description{ Define \code{\link[=df_printer]{df_printer()}} as data.frame print method in an R Markdown document. In a setup run chunk: \if{html}{\out{
}}\preformatted{flextable::use_df_printer() }\if{html}{\out{
}} } \seealso{ \code{\link[=df_printer]{df_printer()}}, \code{\link[=flextable]{flextable()}} } flextable/man/merge_h.Rd0000644000176200001440000000157514476430471014712 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/merge_flextable.R \name{merge_h} \alias{merge_h} \title{Merge flextable cells horizontally} \usage{ merge_h(x, i = NULL, part = "body") } \arguments{ \item{x}{\code{flextable} object} \item{i}{rows where cells have to be merged.} \item{part}{partname of the table where merge has to be done.} } \description{ Merge flextable cells horizontally when consecutive cells have identical values. Text of formatted values are used to compare values. } \examples{ dummy_df <- data.frame( col1 = letters, col2 = letters, stringsAsFactors = FALSE ) ft_merge <- flextable(dummy_df) ft_merge <- merge_h(x = ft_merge) ft_merge } \seealso{ Other flextable merging function: \code{\link{merge_at}()}, \code{\link{merge_h_range}()}, \code{\link{merge_none}()}, \code{\link{merge_v}()} } \concept{flextable merging function} flextable/man/void.Rd0000644000176200001440000000070514476430471014237 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/empty.R \name{void} \alias{void} \title{Delete flextable content} \usage{ void(x, j = NULL, part = "body") } \arguments{ \item{x}{\code{flextable} object} \item{j}{columns selection} \item{part}{partname of the table} } \description{ Set content display as a blank \code{" "}. } \examples{ ftab <- flextable(head(mtcars)) ftab <- void(ftab, ~ vs + am + gear + carb) ftab } flextable/man/as_flextable.glm.Rd0000644000176200001440000000250314476430470016502 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.glm} \alias{as_flextable.glm} \title{Transform a 'glm' object into a flextable} \usage{ \method{as_flextable}{glm}(x, ...) } \arguments{ \item{x}{glm model} \item{...}{unused argument} } \description{ produce a flextable describing a generalized linear model produced by function \code{glm}. You can remove significance stars by setting options \code{options(show.signif.stars = FALSE)}. } \examples{ if (require("broom")) { dat <- attitude dat$high.rating <- (dat$rating > 70) probit.model <- glm(high.rating ~ learning + critical + advance, data = dat, family = binomial(link = "probit")) ft <- as_flextable(probit.model) ft } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/as_highlight.Rd0000644000176200001440000000251214476430470015725 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_highlight} \alias{as_highlight} \title{Highlight chunk} \usage{ as_highlight(x, color) } \arguments{ \item{x}{value, if a chunk, the chunk will be updated} \item{color}{color to use as text highlighting color as character vector.} } \description{ The function is producing a chunk with an highlight chunk. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("Sepal.Length", "dummy") ) ft <- compose(ft, j = "dummy", value = as_paragraph(as_highlight(Sepal.Length, color = "yellow")) ) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/to_html.flextable.Rd0000644000176200001440000000225214515040463016700 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{to_html.flextable} \alias{to_html.flextable} \title{Get HTML code as a string} \usage{ \method{to_html}{flextable}(x, type = c("table", "img"), ...) } \arguments{ \item{x}{a flextable object} \item{type}{output type. one of "table" or "img".} \item{...}{unused} } \value{ If \code{type='img'}, the result will be a string containing HTML code of an image tag, otherwise, the result will be a string containing HTML code of a table tag. } \description{ Generate HTML code of corresponding flextable as an HTML table or an HTML image. } \examples{ library(officer) library(flextable) x <- to_html(as_flextable(cars)) } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()} } \concept{flextable print function} flextable/man/highlight.Rd0000644000176200001440000000405414411071536015236 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{highlight} \alias{highlight} \title{Text highlight color} \usage{ highlight(x, i = NULL, j = NULL, color = "yellow", part = "body", source = j) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{color}{color to use as text highlighting color. If a function, function need to return a character vector of colors.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} \item{source}{if color is a function, source is specifying the dataset column to be used as argument to \code{color}. This is only useful if j is colored with values contained in other columns.} } \description{ Change text highlight color of selected rows and columns of a flextable. A function can be used instead of fixed colors. When \code{color} is a function, it is possible to color cells based on values located in other columns, using hidden columns (those not used by argument \code{colkeys}) is a common use case. The argument \code{source} has to be used to define what are the columns to be used for the color definition and the argument \code{j} has to be used to define where to apply the colors and only accept values from \code{colkeys}. } \examples{ my_color_fun <- function(x) { out <- rep("yellow", length(x)) out[x < quantile(x, .75)] <- "pink" out[x < quantile(x, .50)] <- "wheat" out[x < quantile(x, .25)] <- "gray90" out } ft <- flextable(head(mtcars, n = 10)) ft <- highlight(ft, j = "disp", i = ~ disp > 200, color = "yellow") ft <- highlight(ft, j = ~ drat + wt + qsec, color = my_color_fun) ft } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/autofit.Rd0000644000176200001440000000436514364612403014750 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{autofit} \alias{autofit} \title{Adjusts cell widths and heights} \usage{ autofit( x, add_w = 0.1, add_h = 0.1, part = c("body", "header"), unit = "in", hspans = "none" ) } \arguments{ \item{x}{flextable object} \item{add_w}{extra width to add in inches} \item{add_h}{extra height to add in inches} \item{part}{partname of the table (one of 'all', 'body', 'header' or 'footer')} \item{unit}{unit for add_h and add_w, one of "in", "cm", "mm".} \item{hspans}{specifies how cells that are horizontally are included in the calculation. It must be one of the following values "none", "divided" or "included". If "none", widths of horizontally spanned cells is set to 0 (then do not affect the widths); if "divided", widths of horizontally spanned cells is divided by the number of spanned cells; if "included", all widths (included horizontally spanned cells) will be used in the calculation.} } \description{ compute and apply optimized widths and heights (minimum estimated widths and heights for each table columns and rows in inches returned by function \code{\link[=dim_pretty]{dim_pretty()}}). This function is to be used when the table widths and heights should be adjusted to fit the size of the content. The function does not let you adjust a content that is too wide in a paginated document. It simply calculates the width of the columns so that each content has the minimum width necessary to display the content on one line. Note that this function is not related to 'Microsoft Word' \emph{Autofit} feature. There is an alternative to fixed-width layouts that works well with HTML and Word output that can be set with \code{set_table_properties(layout = "autofit")}, see \code{\link[=set_table_properties]{set_table_properties()}}. } \examples{ ft_1 <- flextable(head(mtcars)) ft_1 ft_2 <- autofit(ft_1) ft_2 } \seealso{ Other flextable dimensions: \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/use_model_printer.Rd0000644000176200001440000000133514255321756017015 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{use_model_printer} \alias{use_model_printer} \title{set model automatic printing as a flextable} \usage{ use_model_printer() } \description{ Define \code{\link[=as_flextable]{as_flextable()}} as print method in an R Markdown document for models of class: \itemize{ \item lm \item glm \item models from package 'lme' and 'lme4' \item htest (t.test, chisq.test, ...) \item gam \item kmeans and pam } In a setup run chunk: \if{html}{\out{
}}\preformatted{flextable::use_model_printer() }\if{html}{\out{
}} } \seealso{ \code{\link[=use_df_printer]{use_df_printer()}}, \code{\link[=flextable]{flextable()}} } flextable/man/linerange.Rd0000644000176200001440000000411514476430471015241 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{linerange} \alias{linerange} \title{Mini linerange chunk wrapper} \usage{ linerange( value, min = NULL, max = NULL, rangecol = "#CCCCCC", stickcol = "#FF0000", bg = "transparent", width = 1, height = 0.2, raster_width = 30, unit = "in" ) } \arguments{ \item{value}{values containing the bar size} \item{min}{min bar size. Default min of value} \item{max}{max bar size. Default max of value} \item{rangecol}{bar color} \item{stickcol}{jauge color} \item{bg}{background color} \item{width, height}{size of the resulting png file in inches} \item{raster_width}{number of pixels used as width when interpolating value.} \item{unit}{unit for width and height, one of "in", "cm", "mm".} } \description{ This function is used to insert lineranges into flextable with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}}. } } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ myft <- flextable(head(iris, n = 10)) myft <- compose(myft, j = 1, value = as_paragraph( linerange(value = Sepal.Length) ), part = "body" ) autofit(myft) } \seealso{ \code{\link[=compose]{compose()}}, \code{\link[=as_paragraph]{as_paragraph()}} Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/theme_apa.Rd0000644000176200001440000000401214476430472015215 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_apa} \alias{theme_apa} \title{Apply APA theme} \usage{ theme_apa(x, ...) } \arguments{ \item{x}{a flextable object} \item{...}{unused} } \description{ Apply theme APA (the stylistic style of the American Psychological Association) to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(mtcars * 22.22)) ft <- theme_apa(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/as_image.Rd0000644000176200001440000000474014476430471015046 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{as_image} \alias{as_image} \title{Image chunk wrapper} \usage{ as_image(src, width = NULL, height = NULL, unit = "in", guess_size = TRUE, ...) } \arguments{ \item{src}{image filename} \item{width, height}{size of the image file. It can be ignored if parameter \code{guess_size=TRUE}, see parameter \code{guess_size}.} \item{unit}{unit for width and height, one of "in", "cm", "mm".} \item{guess_size}{If package 'magick' is installed, this option can be used (set it to \code{TRUE} and don't provide values for paramters \code{width} and \code{height}). When the flextable will be printed, the images will be read and width and height will be guessed. This should be avoid if possible as it can be an extensive task when several images.} \item{...}{unused argument} } \description{ The function lets add images within flextable objects with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}} \if{html}{\out{ as_image illustration }} } } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ img.file <- file.path( R.home("doc"), "html", "logo.jpg" ) if (require("magick")) { myft <- flextable(head(iris)) myft <- compose(myft, i = 1:3, j = 1, value = as_paragraph( as_image(src = img.file), " ", as_chunk(Sepal.Length, props = fp_text_default(color = "red") ) ), part = "body" ) ft <- autofit(myft) ft } } \seealso{ \code{\link[=compose]{compose()}}, \code{\link[=as_paragraph]{as_paragraph()}} Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/colformat_lgl.Rd0000644000176200001440000000222514375473105016120 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_lgl} \alias{colformat_lgl} \title{Format logical cells} \usage{ colformat_lgl( x, i = NULL, j = NULL, true = "true", false = "false", na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{false, true}{string to be used for logical} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format logical cells in a flextable. } \examples{ dat <- data.frame(a = c(TRUE, FALSE), b = c(FALSE, TRUE)) z <- flextable(dat) z <- colformat_lgl(x = z, j = c("a", "b")) autofit(z) } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/plot_chunk.Rd0000644000176200001440000000467314476430471015454 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{plot_chunk} \alias{plot_chunk} \title{Mini plots chunk wrapper} \usage{ plot_chunk( value, width = 1, height = 0.2, type = "box", free_scale = FALSE, unit = "in", ... ) } \arguments{ \item{value}{a numeric vector, stored in a list column.} \item{width, height}{size of the resulting png file in inches} \item{type}{type of the plot: 'box', 'line', 'points' or 'density'.} \item{free_scale}{Should scales be free (TRUE or FALSE, the default value).} \item{unit}{unit for width and height, one of "in", "cm", "mm".} \item{...}{arguments sent to plot functions (see \code{\link[=par]{par()}})} } \description{ This function is used to insert mini plots into flextable with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}}. } Available plots are 'box', 'line', 'points', 'density'. } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ library(data.table) library(flextable) z <- as.data.table(iris) z <- z[, list( Sepal.Length = mean(Sepal.Length, na.rm = TRUE), z = list(.SD$Sepal.Length) ), by = "Species"] ft <- flextable(z, col_keys = c("Species", "Sepal.Length", "box", "density") ) ft <- mk_par(ft, j = "box", value = as_paragraph( plot_chunk( value = z, type = "box", border = "red", col = "transparent" ) )) ft <- mk_par(ft, j = "density", value = as_paragraph( plot_chunk(value = z, type = "dens", col = "red") )) ft <- set_table_properties(ft, layout = "autofit", width = .6) ft <- set_header_labels(ft, box = "boxplot", density = "density") theme_vanilla(ft) } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()} } \concept{chunk elements for paragraph} flextable/man/as_flextable.lm.Rd0000644000176200001440000000233514476430470016336 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.lm} \alias{as_flextable.lm} \title{Transform a 'lm' object into a flextable} \usage{ \method{as_flextable}{lm}(x, ...) } \arguments{ \item{x}{lm model} \item{...}{unused argument} } \description{ produce a flextable describing a linear model produced by function \code{lm}. You can remove significance stars by setting options \code{options(show.signif.stars = FALSE)}. } \examples{ if (require("broom")) { lmod <- lm(rating ~ complaints + privileges + learning + raises + critical, data = attitude) ft <- as_flextable(lmod) ft } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/hyperlink_text.Rd0000644000176200001440000000407314476430470016350 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{hyperlink_text} \alias{hyperlink_text} \title{Chunk of text with hyperlink} \usage{ hyperlink_text(x, props = NULL, formatter = format_fun, url, ...) } \arguments{ \item{x}{text or any element that can be formatted as text with function provided in argument \code{formatter}.} \item{props}{an \code{\link[=fp_text_default]{fp_text_default()}} or \code{\link[officer:fp_text]{officer::fp_text()}} object to be used to format the text. If not specified, it will be the default value corresponding to the cell.} \item{formatter}{a function that will format x as a character vector.} \item{url}{url to be used} \item{...}{additional arguments for \code{formatter} function.} } \description{ The function lets add hyperlinks within flextable objects. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. URL are not encoded, they are preserved 'as is'. } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. } \examples{ dat <- data.frame( col = "Google it", href = "https://www.google.fr/search?source=hp&q=flextable+R+package", stringsAsFactors = FALSE ) ftab <- flextable(dat) ftab <- compose( x = ftab, j = "col", value = as_paragraph( "This is a link: ", hyperlink_text(x = col, url = href) ) ) ftab } \seealso{ \code{\link[=compose]{compose()}} Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/prepend_chunks.Rd0000644000176200001440000000202314375473105016300 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/append_chunk.R \name{prepend_chunks} \alias{prepend_chunks} \title{Prepend chunks to flextable content} \usage{ prepend_chunks(x, ..., i = NULL, j = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{...}{chunks to be prepended, see \code{\link[=as_chunk]{as_chunk()}}, \code{\link[=gg_chunk]{gg_chunk()}} and other chunk elements for paragraph.} \item{i}{rows selection} \item{j}{column selection} \item{part}{partname of the table (one of 'body', 'header', 'footer')} } \description{ prepend chunks (for example chunk \code{\link[=as_chunk]{as_chunk()}}) in a flextable. } \examples{ x <- flextable(head(iris)) x <- prepend_chunks( x, i = 1, j = 1, colorize(as_b("Hello "), color = "red"), colorize(as_i("World"), color = "magenta") ) x } \seealso{ Other functions for mixed content paragraphs: \code{\link{append_chunks}()}, \code{\link{as_paragraph}()}, \code{\link{compose}()} } \concept{functions for mixed content paragraphs} flextable/man/knit_print.flextable.Rd0000644000176200001440000001641714515040434017421 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{knit_print.flextable} \alias{knit_print.flextable} \title{Render flextable with 'knitr'} \usage{ \method{knit_print}{flextable}(x, ...) } \arguments{ \item{x}{a \code{flextable} object} \item{...}{unused.} } \description{ Function used to render flextable in knitr/rmarkdown documents. You should not call this method directly. This function is used by the knitr package to automatically display a flextable in an "R Markdown" document from a chunk. However, it is recommended to read its documentation in order to get familiar with the different options available. R Markdown outputs can be : \itemize{ \item HTML \item 'Microsoft Word' \item 'Microsoft PowerPoint' \item PDF } \if{html}{\figure{fig_formats.png}{options: width="200"}} Table captioning is a flextable feature compatible with R Markdown documents. The feature is available for HTML, PDF and Word documents. Compatibility with the "bookdown" package is also ensured, including the ability to produce captions so that they can be used in cross-referencing. For Word, it's recommanded to work with package 'officedown' that supports all features of flextable. } \note{ Supported formats require some minimum \href{https://pandoc.org/installing.html}{pandoc} versions: \tabular{rc}{ \strong{Output format} \tab \strong{pandoc minimal version} \cr HTML \tab >= 1.12\cr Word (docx) \tab >= 2.0 \cr PowerPoint (pptx) \tab >= 2.4 \cr PDF \tab >= 1.12 } } \section{Chunk options}{ Some features, often specific to an output format, are available to help you configure some global settings relatve to the table output. knitr's chunk options are to be used to change the default settings: \itemize{ \item HTML, PDF and Word: \itemize{ \item \code{ft.align}: flextable alignment, supported values are 'left', 'center' and 'right'. Its default value is 'center'. } \item HTML only: \itemize{ \item \code{ft.htmlscroll}, can be \code{TRUE} or \code{FALSE} (default) to enable horizontal scrolling. Use \code{\link[=set_table_properties]{set_table_properties()}} for more options about scrolling. } \item Word only: \itemize{ \item \code{ft.split} Word option 'Allow row to break across pages' can be activated when TRUE (default value). \item \code{ft.keepnext} defunct in favor of \code{\link[=paginate]{paginate()}} } \item PDF only: \itemize{ \item \code{ft.tabcolsep} space between the text and the left/right border of its containing cell, the default value is 0 points. \item \code{ft.arraystretch} height of each row relative to its default height, the default value is 1.5. \item \code{ft.latex.float} type of floating placement in the document, one of: \itemize{ \item 'none' (the default value), table is placed after the preceding paragraph. \item 'float', table can float to a place in the text where it fits best \item 'wrap-r', wrap text around the table positioned to the right side of the text \item 'wrap-l', wrap text around the table positioned to the left side of the text \item 'wrap-i', wrap text around the table positioned inside edge-near the binding \item 'wrap-o', wrap text around the table positioned outside edge-far from the binding } } \item PowerPoint only: \itemize{ \item \code{ft.left}, \code{ft.top} Position should be defined with these options. Theses are the top left coordinates in inches of the placeholder that will contain the table. Their default values are 1 and 2 inches. } } If some values are to be used all the time in the same document, it is recommended to set these values in a 'knitr r chunk' by using function \code{knitr::opts_chunk$set(ft.split=FALSE, ...)}. } \section{Table caption}{ Captions can be defined in two ways. The first is with the \code{\link[=set_caption]{set_caption()}} function. If it is used, the other method will be ignored. The second method is by using knitr chunk option \code{tab.cap}. \if{html}{\out{
}}\preformatted{set_caption(x, caption = "my caption") }\if{html}{\out{
}} If \code{set_caption} function is not used, caption identifier will be read from knitr's chunk option \code{tab.id}. Note that in a bookdown and when not using \code{officedown::rdocx_document()}, the usual numbering feature of bookdown is used. \code{tab.id='my_id'}. Some options are available to customise captions for any output:\tabular{lcc}{ \strong{label} \tab \strong{name} \tab \strong{value} \cr Word stylename to use for table captions. \tab tab.cap.style \tab NULL \cr caption id/bookmark \tab tab.id \tab NULL \cr caption \tab tab.cap \tab NULL \cr display table caption on top of the table or not \tab tab.topcaption \tab TRUE \cr caption table sequence identifier. \tab tab.lp \tab "tab:" \cr } Word output when \code{officedown::rdocx_document()} is used is coming with more options such as ability to choose the prefix for numbering chunk for example. The table below expose these options:\tabular{lcc}{ \strong{label} \tab \strong{name} \tab \strong{value} \cr prefix for numbering chunk (default to "Table "). \tab tab.cap.pre \tab Table \cr suffix for numbering chunk (default to ": "). \tab tab.cap.sep \tab " :" \cr title number depth \tab tab.cap.tnd \tab 0 \cr caption prefix formatting properties \tab tab.cap.fp_text \tab fp_text_lite(bold = TRUE) \cr separator to use between title number and table number. \tab tab.cap.tns \tab "-" \cr } } \section{HTML output}{ HTML output is using shadow dom to encapsule the table into an isolated part of the page so that no clash happens with styles. } \section{PDF output}{ Some features are not implemented in PDF due to technical infeasibility. These are the padding, line_spacing and height properties. Note also justified text is not supported and is transformed to left. It is recommended to set theses values in a 'knitr r chunk' so that they are permanent all along the document: \code{knitr::opts_chunk$set(ft.tabcolsep=0, ft.latex.float = "none")}. See \code{\link[=add_latex_dep]{add_latex_dep()}} if caching flextable results in 'R Markdown' documents. } \section{PowerPoint output}{ Auto-adjust Layout is not available for PowerPoint, PowerPoint only support fixed layout. It's then often necessary to call function \code{\link[=autofit]{autofit()}} so that the columns' widths are adjusted if user does not provide the withs. Images cannot be integrated into tables with the PowerPoint format. } \examples{ \dontrun{ library(rmarkdown) if (pandoc_available() && pandoc_version() > numeric_version("2")) { demo_loop <- system.file( package = "flextable", "examples/rmd", "demo.Rmd" ) rmd_file <- tempfile(fileext = ".Rmd") file.copy(demo_loop, to = rmd_file, overwrite = TRUE) render( input = rmd_file, output_format = "html_document", output_file = "demo.html" ) } } } \seealso{ \code{\link[=paginate]{paginate()}} Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/height.Rd0000644000176200001440000000311514364612403014535 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{height} \alias{height} \alias{height_all} \title{Set flextable rows height} \usage{ height(x, i = NULL, height, part = "body", unit = "in") height_all(x, height, part = "all", unit = "in") } \arguments{ \item{x}{flextable object} \item{i}{rows selection} \item{height}{height in inches} \item{part}{partname of the table} \item{unit}{unit for height, one of "in", "cm", "mm".} } \description{ control rows height for a part of the flextable when the line height adjustment is "atleast" or "exact" (see \code{\link[=hrule]{hrule()}}). } \note{ This function has no effect when the rule for line height is set to "auto" (see \code{\link[=hrule]{hrule()}}), which is the default case, except with PowerPoint which does not support this automatic line height adjustment feature. } \section{height_all}{ \code{height_all} is a convenient function for setting the same height to all rows (selected with argument \code{part}). } \examples{ ft_1 <- flextable(head(iris)) ft_1 <- height(ft_1, height = .5) ft_1 <- hrule(ft_1, rule = "exact") ft_1 ft_2 <- flextable(head(iris)) ft_2 <- height_all(ft_2, height = 1) ft_2 <- hrule(ft_2, rule = "exact") ft_2 } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/hline_top.Rd0000644000176200001440000000231614476430471015257 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{hline_top} \alias{hline_top} \title{Set top horizontal border} \usage{ hline_top(x, j = NULL, border = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{j}{columns selection} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying an horizontal border to the top of one or all parts of a flextable. The line is the top border of selected parts. } \examples{ library(officer) big_border <- fp_border(color = "orange", width = 3) ft <- flextable(head(iris)) ft <- border_remove(x = ft) # add horizontal border on top ft <- hline_top(ft, part = "all", border = big_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/as_grouped_data.Rd0000644000176200001440000000207714476430470016422 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_grouped_data} \alias{as_grouped_data} \title{Add row separators to grouped data} \usage{ as_grouped_data(x, groups, columns = NULL, expand_single = TRUE) } \arguments{ \item{x}{dataset} \item{groups}{columns names to be used as row separators.} \item{columns}{columns names to keep} \item{expand_single}{if FALSE, groups with only one row will not be expanded with a title row. If TRUE (the default), single row groups and multi-row groups are all restructured.} } \description{ Repeated consecutive values of group columns will be used to define the title of the groups and will be added as a row title. } \examples{ # as_grouped_data ----- library(data.table) CO2 <- CO2 setDT(CO2) CO2$conc <- as.integer(CO2$conc) data_co2 <- dcast(CO2, Treatment + conc ~ Type, value.var = "uptake", fun.aggregate = mean ) data_co2 data_co2 <- as_grouped_data(x = data_co2, groups = c("Treatment")) data_co2 } \seealso{ \code{\link[=as_flextable.grouped_data]{as_flextable.grouped_data()}} } flextable/man/colformat_date.Rd0000644000176200001440000000225214402205763016251 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_date} \alias{colformat_date} \title{Format date cells} \usage{ colformat_date( x, i = NULL, j = NULL, fmt_date = get_flextable_defaults()$fmt_date, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{fmt_date}{see \code{\link[=strptime]{strptime()}}} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format date cells in a flextable. } \examples{ dat <- data.frame( z = Sys.Date() + 1:3, w = Sys.Date() - 1:3 ) ft <- flextable(dat) ft <- colformat_date(x = ft) ft <- autofit(ft) ft } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/theme_box.Rd0000644000176200001440000000365514364612403015250 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_box} \alias{theme_box} \title{Apply box theme} \usage{ theme_box(x) } \arguments{ \item{x}{a flextable object} } \description{ Apply theme box to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_box(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/colformat_num.Rd0000644000176200001440000000520014402205763016127 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_num} \alias{colformat_num} \title{Format numeric cells} \usage{ colformat_num( x, i = NULL, j = NULL, big.mark = get_flextable_defaults()$big.mark, decimal.mark = get_flextable_defaults()$decimal.mark, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "", ... ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{big.mark, decimal.mark}{see \code{\link[=format]{format()}}} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} \item{...}{additional argument for function \code{\link[=format]{format()}}, \code{scientific} and \code{digits} can not be used.} } \description{ Format numeric cells in a flextable. The function is different from \code{\link[=colformat_double]{colformat_double()}} on numeric type columns. The function uses the \code{\link[=format]{format()}} function of R on numeric type columns. So this is normally what you see on the R console most of the time (but scientific mode is disabled and NA are replaced). } \section{format call}{ Function \code{\link[=format]{format()}} is called with the following values: \itemize{ \item \code{trim} is set to TRUE, \item \code{scientific} is set to FALSE, \item \code{big.mark} is set to the value of \code{big.mark} argument, \item \code{decimal.mark} is set to the value of \code{decimal.mark} argument, \item other arguments are passed 'as is' to the format function. } argument \code{digits} is ignored as it is not the same \code{digits} that users want, this one will be used by \code{\link[=format]{format()}} and not \code{\link[=formatC]{formatC()}}. To change the digit argument use \code{options(digits=4)} instead. This argument will not be changed because \code{colformat_num()} is supposed to format things roughly as what you see on the R console. If these functions does not fit your needs, use \code{\link[=set_formatter]{set_formatter()}} that lets you use any format function. } \examples{ dat <- mtcars dat[2, 1] <- NA ft <- flextable(head(dat)) ft <- colformat_num( x = ft, big.mark = " ", decimal.mark = ",", na_str = "N/A" ) ft <- autofit(ft) ft } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/as_flextable.xtable.Rd0000644000176200001440000000561014410655214017175 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/xtable_to_flextable.R \name{as_flextable.xtable} \alias{as_flextable.xtable} \title{Transform a 'xtable' object into a flextable} \usage{ \method{as_flextable}{xtable}( x, text.properties = fp_text_default(), format.args = getOption("xtable.format.args", NULL), rowname_col = "rowname", hline.after = getOption("xtable.hline.after", c(-1, 0, nrow(x))), NA.string = getOption("xtable.NA.string", ""), include.rownames = TRUE, rotate.colnames = getOption("xtable.rotate.colnames", FALSE), ... ) } \arguments{ \item{x}{\code{xtable} object} \item{text.properties}{default text formatting properties} \item{format.args}{List of arguments for the formatC function. See argument \code{format.args} of \code{print.xtable}. Not yet implemented.} \item{rowname_col}{colname used for row names column} \item{hline.after}{see \code{?print.xtable}.} \item{NA.string}{see \code{?print.xtable}.} \item{include.rownames}{see \code{?print.xtable}.} \item{rotate.colnames}{see \code{?print.xtable}.} \item{...}{unused arguments} } \description{ Get a \code{flextable} object from a \code{xtable} object. } \examples{ library(officer) if( require("xtable") ){ data(tli) tli.table <- xtable(tli[1:10, ]) align(tli.table) <- rep("r", 6) align(tli.table) <- "|r|r|clr|r|" ft_1 <- as_flextable( tli.table, rotate.colnames = TRUE, include.rownames = FALSE) ft_1 <- height(ft_1, i = 1, part = "header", height = 1) ft_1 \donttest{ Grade3 <- c("A","B","B","A","B","C","C","D","A","B", "C","C","C","D","B","B","D","C","C","D") Grade6 <- c("A","A","A","B","B","B","B","B","C","C", "A","C","C","C","D","D","D","D","D","D") Cohort <- table(Grade3, Grade6) ft_2 <- as_flextable(xtable(Cohort)) ft_2 <- set_header_labels(ft_2, rowname = "Grade 3") ft_2 <- autofit(ft_2) ft_2 <- add_header(ft_2, A = "Grade 6") ft_2 <- merge_at(ft_2, i = 1, j = seq_len( ncol(Cohort) ) + 1, part = "header" ) ft_2 <- bold(ft_2, j = 1, bold = TRUE, part = "body") ft_2 <- height_all(ft_2, part = "header", height = .4) ft_2 temp.ts <- ts(cumsum(1 + round(rnorm(100), 0)), start = c(1954, 7), frequency = 12) ft_3 <- as_flextable(x = xtable(temp.ts, digits = 0), NA.string = "-") ft_3 } detach("package:xtable", unload = TRUE) } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/set_header_footer_df.Rd0000644000176200001440000000452414515157112017423 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{set_header_footer_df} \alias{set_header_footer_df} \alias{set_header_df} \alias{set_footer_df} \title{Set flextable's header or footer rows} \usage{ set_header_df(x, mapping = NULL, key = "col_keys") set_footer_df(x, mapping = NULL, key = "col_keys") } \arguments{ \item{x}{a \code{flextable} object} \item{mapping}{a \code{data.frame} specyfing for each colname content of the column.} \item{key}{column to use as key when joigning data_mapping.} } \description{ Use a data.frame to specify flextable's header or footer rows. The data.frame must contain a column whose values match flextable \code{col_keys} argument, this column will be used as join key. The other columns will be displayed as header or footer rows. The leftmost column is used as the top header/footer row and the rightmost column is used as the bottom header/footer row. } \examples{ typology <- data.frame( col_keys = c( "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species" ), what = c("Sepal", "Sepal", "Petal", "Petal", "Species"), measure = c("Length", "Width", "Length", "Width", "Species"), stringsAsFactors = FALSE ) ft_1 <- flextable(head(iris)) ft_1 <- set_header_df(ft_1, mapping = typology, key = "col_keys") ft_1 <- merge_h(ft_1, part = "header") ft_1 <- merge_v(ft_1, j = "Species", part = "header") ft_1 <- theme_vanilla(ft_1) ft_1 <- fix_border_issues(ft_1) ft_1 typology <- data.frame( col_keys = c( "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species" ), unit = c("(cm)", "(cm)", "(cm)", "(cm)", ""), stringsAsFactors = FALSE ) ft_2 <- set_footer_df(ft_1, mapping = typology, key = "col_keys") ft_2 <- italic(ft_2, italic = TRUE, part = "footer") ft_2 <- theme_booktabs(ft_2) ft_2 <- fix_border_issues(ft_2) ft_2 } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/as_b.Rd0000644000176200001440000000230714476430470014201 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_b} \alias{as_b} \title{Bold chunk} \usage{ as_b(x) } \arguments{ \item{x}{value, if a chunk, the chunk will be updated} } \description{ The function is producing a chunk with bold font. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("Sepal.Length", "dummy") ) ft <- compose(ft, j = "dummy", value = as_paragraph( as_b(Sepal.Length) ) ) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/ph_with.flextable.Rd0000644000176200001440000000232514375473105016704 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ph_with.R \name{ph_with.flextable} \alias{ph_with.flextable} \title{Add a flextable into a PowerPoint slide} \usage{ \method{ph_with}{flextable}(x, value, location, ...) } \arguments{ \item{x}{a pptx device} \item{value}{flextable object} \item{location}{a location for a placeholder. See \code{\link[officer:ph_location_type]{officer::ph_location_type()}} for example.} \item{...}{unused arguments.} } \description{ Add a flextable in a PowerPoint document object produced by \code{\link[officer:read_pptx]{officer::read_pptx()}}. } \note{ The width and height of the table can not be set with \code{location}. Use functions \code{\link[=width]{width()}}, \code{\link[=height]{height()}}, \code{\link[=autofit]{autofit()}} and \code{\link[=dim_pretty]{dim_pretty()}} instead. The overall size is resulting from cells, paragraphs and text properties (i.e. padding, font size, border widths). } \examples{ library(officer) ft <- flextable(head(iris)) doc <- read_pptx() doc <- add_slide(doc, "Title and Content", "Office Theme") doc <- ph_with(doc, ft, location = ph_location_left()) fileout <- tempfile(fileext = ".pptx") print(doc, target = fileout) } flextable/man/theme_booktabs.Rd0000644000176200001440000000404614364612403016257 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_booktabs} \alias{theme_booktabs} \title{Apply booktabs theme} \usage{ theme_booktabs(x, bold_header = FALSE, ...) } \arguments{ \item{x}{a flextable object} \item{bold_header}{header will be bold if TRUE.} \item{...}{unused} } \description{ Apply theme booktabs to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_booktabs(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/as_sub.Rd0000644000176200001440000000242014476430470014545 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_sub} \alias{as_sub} \title{Subscript chunk} \usage{ as_sub(x) } \arguments{ \item{x}{value, if a chunk, the chunk will be updated} } \description{ The function is producing a chunk with subscript vertical alignment. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("dummy")) ft <- compose(ft, i = 1, j = "dummy", part = "header", value = as_paragraph( as_sub("Sepal.Length"), " anything " ) ) ft <- autofit(ft) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/add_body_row.Rd0000644000176200001440000000544114515157112015724 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_body_row} \alias{add_body_row} \title{Add body labels} \usage{ add_body_row(x, top = TRUE, values = list(), colwidths = integer(0)) } \arguments{ \item{x}{a flextable object} \item{top}{should the row be inserted at the top or the bottom.} \item{values}{values to add. It can be a \code{list}, a \code{character()} vector or a call to \code{\link[=as_paragraph]{as_paragraph()}}. If it is a list, it can be a named list with the names of the columns of the original data.frame or the \code{colkeys}; this is the recommended method because it allows to keep the original data types and therefore allows to perform conditional formatting. If a character, columns of the original data.frame stored in the flextable object are changed to \code{character()}; this is often not an issue with footer and header but can be inconvenient if adding rows into body as it will change data types to character and prevent efficient conditional formatting.} \item{colwidths}{the number of columns to merge in the row for each label} } \description{ Add a row of new columns labels in body part. Labels can be spanned along multiple columns, as merged cells. Labels are associated with a number of columns to merge that default to one if not specified. In this case, you have to make sure that the number of labels is equal to the number of columns displayed. The function can add only one single row by call. Labels can also be formatted with \code{\link[=as_paragraph]{as_paragraph()}}. } \examples{ library(flextable) ft01 <- fp_text_default(color = "red") ft02 <- fp_text_default(color = "orange") pars <- as_paragraph( as_chunk(c("(1)", "(2)"), props = ft02), " ", as_chunk( c( "My tailor is rich", "My baker is rich" ), props = ft01 ) ) ft_1 <- flextable(head(mtcars)) ft_1 <- add_body_row(ft_1, values = pars, colwidths = c(5, 6), top = FALSE ) ft_1 <- add_body_row(ft_1, values = pars, colwidths = c(3, 8), top = TRUE ) ft_1 <- theme_box(ft_1) ft_1 ft_2 <- flextable(head(airquality)) ft_2 <- add_body_row(ft_2, values = c("blah", "bleeeh"), colwidths = c(4, 2), top = TRUE ) ft_2 <- theme_box(ft_2) ft_2 } \seealso{ \code{\link[=flextable]{flextable()}}, \code{\link[=set_caption]{set_caption()}} Other functions for row and column operations in a flextable: \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/style.Rd0000644000176200001440000000226714364612403014434 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{style} \alias{style} \title{Set flextable style} \usage{ style( x, i = NULL, j = NULL, pr_t = NULL, pr_p = NULL, pr_c = NULL, part = "body" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{pr_t}{object(s) of class \code{fp_text}} \item{pr_p}{object(s) of class \code{fp_par}} \item{pr_c}{object(s) of class \code{fp_cell}} \item{part}{partname of the table (one of 'all', 'body', 'header' or 'footer')} } \description{ Modify flextable text, paragraphs and cells formatting properties. It allows to specify a set of formatting properties for a selection instead of using multiple functions (.i.e \code{bold}, \code{italic}, \code{bg}) that should all be applied to the same selection of rows and columns. } \examples{ library(officer) def_cell <- fp_cell(border = fp_border(color = "wheat")) def_par <- fp_par(text.align = "center") ft <- flextable(head(mtcars)) ft <- style(ft, pr_c = def_cell, pr_p = def_par, part = "all") ft <- style(ft, ~ drat > 3.5, ~ vs + am + gear + carb, pr_t = fp_text(color = "red", italic = TRUE) ) ft } flextable/man/ncol_keys.Rd0000644000176200001440000000126714021743006015253 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/nrowcol.R \name{ncol_keys} \alias{ncol_keys} \title{Number of columns} \usage{ ncol_keys(x) } \arguments{ \item{x}{flextable object} } \description{ returns the number of columns displayed } \examples{ library(flextable) ft <- qflextable(head(cars)) ncol_keys(ft) } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/separate_header.Rd0000644000176200001440000000476114515157112016410 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{separate_header} \alias{separate_header} \title{Separate collapsed colnames into multiple rows} \usage{ separate_header( x, opts = c("span-top", "center-hspan", "bottom-vspan", "default-theme"), split = "[_\\\\.]", fixed = FALSE ) } \arguments{ \item{x}{a flextable object} \item{opts}{optional treatments to apply to the resulting header part as a character vector with multiple supported values. The supported values are: \itemize{ \item "span-top": span empty cells with the first non empty cell, this operation is made column by column. \item "center-hspan": center the cells that are horizontally spanned. \item "bottom-vspan": bottom align the cells treated when "span-top" is applied. \item "default-theme": apply to the new header part the theme set in \code{set_flextable_defaults(theme_fun = ...)}. }} \item{split}{a regular expression (unless \code{fixed = TRUE}) to use for splitting.} \item{fixed}{logical. If TRUE match \code{split} exactly, otherwise use regular expressions.} } \description{ If your variable names contain multiple delimited labels, they will be separated and placed in their own rows. \if{html}{\out{ add_header illustration }} } \examples{ library(flextable) x <- data.frame( Species = as.factor(c("setosa", "versicolor", "virginica")), Sepal.Length_mean = c(5.006, 5.936, 6.588), Sepal.Length_sd = c(0.35249, 0.51617, 0.63588), Sepal.Width_mean = c(3.428, 2.77, 2.974), Sepal.Width_sd = c(0.37906, 0.3138, 0.3225), Petal.Length_mean = c(1.462, 4.26, 5.552), Petal.Length_sd = c(0.17366, 0.46991, 0.55189), Petal.Width_mean = c(0.246, 1.326, 2.026), Petal.Width_sd = c(0.10539, 0.19775, 0.27465) ) ft_1 <- flextable(x) ft_1 <- colformat_double(ft_1, digits = 2) ft_1 <- theme_box(ft_1) ft_1 <- separate_header( x = ft_1, opts = c("span-top", "bottom-vspan") ) ft_1 } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/dim.flextable.Rd0000644000176200001440000000140114015203005015762 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{dim.flextable} \alias{dim.flextable} \title{Get widths and heights of flextable} \usage{ \method{dim}{flextable}(x) } \arguments{ \item{x}{flextable object} } \description{ returns widths and heights for each table columns and rows. Values are expressed in inches. } \examples{ ftab <- flextable(head(iris)) dim(ftab) } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/fmt_dbl.Rd0000644000176200001440000000150314476430471014702 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_dbl} \alias{fmt_dbl} \title{Format numerical data as percentages} \usage{ fmt_dbl(x) } \arguments{ \item{x}{numeric values} } \description{ The function formats numeric vectors as percentages. } \examples{ library(flextable) df <- data.frame(zz = .45) ft_1 <- flextable(df) ft_1 <- mk_par( x = ft_1, j = 1, part = "body", value = as_paragraph(as_chunk(zz, formatter = fmt_dbl)) ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_2stats}()}, \code{\link{fmt_avg_dev}()}, \code{\link{fmt_header_n}()}, \code{\link{fmt_int}()}, \code{\link{fmt_n_percent}()}, \code{\link{fmt_pct}()} } \concept{text formatter functions} flextable/man/as_flextable.table.Rd0000644000176200001440000000225014425265521017006 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/df_printer.R \name{as_flextable.table} \alias{as_flextable.table} \title{Transform a 'table' object into a flextable} \usage{ \method{as_flextable}{table}(x, ...) } \arguments{ \item{x}{table object} \item{...}{arguments used by \code{\link[=proc_freq]{proc_freq()}}.} } \description{ produce a flextable describing a count table produced by function \code{table()}. This function uses the \code{\link[=proc_freq]{proc_freq()}} function. } \examples{ tab <- with(warpbreaks, table(wool, tension)) ft <- as_flextable(tab) ft } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/border_inner.Rd0000644000176200001440000000226114476430470015744 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{border_inner} \alias{border_inner} \title{Set vertical & horizontal inner borders} \usage{ border_inner(x, border = NULL, part = "all") } \arguments{ \item{x}{a flextable object} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying a vertical and horizontal borders to inner content of one or all parts of a flextable. } \examples{ library(officer) std_border <- fp_border(color = "orange", width = 1) dat <- iris[c(1:5, 51:55, 101:105), ] ft <- flextable(dat) ft <- border_remove(x = ft) # add inner vertical borders ft <- border_inner(ft, border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/fmt_n_percent.Rd0000644000176200001440000000254414476430471016124 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_n_percent} \alias{fmt_n_percent} \title{Format content for count data} \usage{ fmt_n_percent(n, pct, digit = 1) } \arguments{ \item{n}{count values} \item{pct}{percent values} \item{digit}{number of digits for the percentages} } \description{ The function formats counts and percentages as \verb{n (xx.x\%)}. If percentages are missing, they are not printed. } \examples{ library(flextable) df <- structure( list( cut = structure( .Data = 1:5, levels = c( "Fair", "Good", "Very Good", "Premium", "Ideal" ), class = c("ordered", "factor") ), n = c(1610L, 4906L, 12082L, 13791L, 21551L), pct = c(0.0299, 0.0909, 0.2239, 0.2557, 0.3995) ), row.names = c(NA, -5L), class = "data.frame" ) ft_1 <- flextable(df, col_keys = c("cut", "txt")) ft_1 <- mk_par( x = ft_1, j = "txt", value = as_paragraph(fmt_n_percent(n, pct)) ) ft_1 <- align(ft_1, j = "txt", part = "all", align = "right") ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_2stats}()}, \code{\link{fmt_avg_dev}()}, \code{\link{fmt_dbl}()}, \code{\link{fmt_header_n}()}, \code{\link{fmt_int}()}, \code{\link{fmt_pct}()} } \concept{text formatter functions} flextable/man/as_flextable.gam.Rd0000644000176200001440000000255614410655214016470 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable_gam.R \name{as_flextable.gam} \alias{as_flextable.gam} \title{Transform a 'gam' model into a flextable} \usage{ \method{as_flextable}{gam}(x, ...) } \arguments{ \item{x}{gam model} \item{...}{unused argument} } \description{ produce a flextable describing a generalized additive model produced by function \code{mgcv::gam}. \if{html}{\out{ as_flextable.gam illustration }} } \examples{ if (require("mgcv")) { set.seed(2) # Simulated data dat <- gamSim(1, n = 400, dist = "normal", scale = 2) # basic GAM model b <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat) ft <- as_flextable(b) ft } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/hline_bottom.Rd0000644000176200001440000000235414476430471015763 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{hline_bottom} \alias{hline_bottom} \title{Set bottom horizontal border} \usage{ hline_bottom(x, j = NULL, border = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{j}{columns selection} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying an horizontal border to the bottom of one or all parts of a flextable. The line is the bottom border of selected parts. } \examples{ library(officer) big_border <- fp_border(color = "orange", width = 3) ft <- flextable(head(iris)) ft <- border_remove(x = ft) # add/replace horizontal border on bottom ft <- hline_bottom(ft, part = "body", border = big_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/colorize.Rd0000644000176200001440000000246714476430470015132 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{colorize} \alias{colorize} \title{Colorize chunk} \usage{ colorize(x, color) } \arguments{ \item{x}{value, if a chunk, the chunk will be updated} \item{color}{color to use as text highlighting color as character vector.} } \description{ The function is producing a chunk with a font in color. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("Sepal.Length", "dummy") ) ft <- compose(ft, j = "dummy", value = as_paragraph(colorize(Sepal.Length, color = "red")) ) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/as_chunk.Rd0000644000176200001440000000361314476430470015071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_chunk} \alias{as_chunk} \title{Chunk of text wrapper} \usage{ as_chunk(x, props = NULL, formatter = format_fun, ...) } \arguments{ \item{x}{text or any element that can be formatted as text with function provided in argument \code{formatter}.} \item{props}{an \code{\link[=fp_text_default]{fp_text_default()}} or \code{\link[officer:fp_text]{officer::fp_text()}} object to be used to format the text. If not specified, it will be the default value corresponding to the cell.} \item{formatter}{a function that will format x as a character vector.} \item{...}{additional arguments for \code{formatter} function.} } \description{ The function lets add formated text in flextable cells. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. It should be used inside a call to \code{\link[=as_paragraph]{as_paragraph()}}. } \examples{ library(officer) ft <- flextable(head(iris)) ft <- compose(ft, j = "Sepal.Length", value = as_paragraph( "Sepal.Length value is ", as_chunk(Sepal.Length, props = fp_text(color = "red")) ), part = "body" ) ft <- color(ft, color = "gray40", part = "all") ft <- autofit(ft) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/fix_border_issues.Rd0000644000176200001440000000201014476430470017002 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/border_fix.R \name{fix_border_issues} \alias{fix_border_issues} \title{Fix border issues when cell are merged} \usage{ fix_border_issues(x, part = "all") } \arguments{ \item{x}{flextable object} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ When cells are merged, the rendered borders will be those of the first cell. If a column is made of three merged cells, the bottom border that will be seen will be the bottom border of the first cell in the column. From a user point of view, this is wrong, the bottom should be the one defined for cell 3. This function modify the border values to avoid that effect. } \examples{ library(officer) dat <- data.frame(a = 1:5, b = 6:10) ft <- flextable(dat) ft <- theme_box(ft) ft <- merge_at(ft, i = 4:5, j = 1, part = "body") ft <- hline(ft, i = 5, part = "body", border = fp_border(color = "red", width = 5) ) print(ft) ft <- fix_border_issues(ft) print(ft) } flextable/man/italic.Rd0000644000176200001440000000176614411071536014543 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{italic} \alias{italic} \title{Set italic font} \usage{ italic(x, i = NULL, j = NULL, italic = TRUE, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{italic}{boolean value} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change font decoration of selected rows and columns of a flextable. } \examples{ ft <- flextable(head(mtcars)) ft <- italic(ft, italic = TRUE, part = "header") } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/delete_part.Rd0000644000176200001440000000201714515157112015554 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{delete_part} \alias{delete_part} \title{Delete flextable part} \usage{ delete_part(x, part = "header") } \arguments{ \item{x}{a \code{flextable} object} \item{part}{partname of the table to delete (one of 'body', 'header' or 'footer').} } \description{ indicate to not print a part of the flextable, i.e. an header, footer or the body. } \examples{ ft <- flextable(head(iris)) ft <- delete_part(x = ft, part = "header") ft } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/vline_right.Rd0000644000176200001440000000235714476430471015615 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{vline_right} \alias{vline_right} \title{Set flextable right vertical borders} \usage{ vline_right(x, i = NULL, border = NULL, part = "all") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying vertical borders to the right side of one or all parts of a flextable. The line is the right border of selected cells of the last column. } \examples{ library(officer) std_border <- fp_border(color = "orange") ft <- flextable(head(iris)) ft <- border_remove(x = ft) # add vertical border on the left side of the table ft <- vline_right(ft, border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/as_flextable.data.frame.Rd0000644000176200001440000000373014410655214017721 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/df_printer.R \name{as_flextable.data.frame} \alias{as_flextable.data.frame} \title{Transform and summarise a 'data.frame' into a flextable Simple summary of a data.frame as a flextable} \usage{ \method{as_flextable}{data.frame}( x, max_row = 10, split_colnames = FALSE, short_strings = FALSE, short_size = 35, short_suffix = "...", do_autofit = TRUE, show_coltype = TRUE, color_coltype = "#999999", ... ) } \arguments{ \item{x}{a data.frame} \item{max_row}{The number of rows to print. Default to 10.} \item{split_colnames}{Should the column names be split (with non alpha-numeric characters). Default to FALSE.} \item{short_strings}{Should the character column be shorten. Default to FALSE.} \item{short_size}{Maximum length of character column if \code{short_strings} is TRUE. Default to 35.} \item{short_suffix}{Suffix to add when character values are shorten. Default to "...".} \item{do_autofit}{Use \code{\link[=autofit]{autofit()}} before rendering the table. Default to TRUE.} \item{show_coltype}{Show column types. Default to TRUE.} \item{color_coltype}{Color to use for column types. Default to "#999999".} \item{...}{unused arguments} } \description{ It displays the first rows and shows the column types. If there is only one row, a simplified vertical table is produced. } \examples{ as_flextable(mtcars) } \seealso{ Other as_flextable methods: \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/as_flextable.merMod.Rd0000644000176200001440000000357314476430470017156 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.merMod} \alias{as_flextable.merMod} \alias{as_flextable.lme} \alias{as_flextable.gls} \alias{as_flextable.nlme} \alias{as_flextable.brmsfit} \alias{as_flextable.glmmTMB} \alias{as_flextable.glmmadmb} \title{Transform a mixed model into a flextable} \usage{ \method{as_flextable}{merMod}(x, add.random = TRUE, ...) \method{as_flextable}{lme}(x, add.random = TRUE, ...) \method{as_flextable}{gls}(x, add.random = TRUE, ...) \method{as_flextable}{nlme}(x, add.random = TRUE, ...) \method{as_flextable}{brmsfit}(x, add.random = TRUE, ...) \method{as_flextable}{glmmTMB}(x, add.random = TRUE, ...) \method{as_flextable}{glmmadmb}(x, add.random = TRUE, ...) } \arguments{ \item{x}{a mixed model} \item{add.random}{TRUE or FALSE, if TRUE random effects are added to the table.} \item{...}{unused argument} } \description{ produce a flextable describing a mixed model. The function is only using package 'broom.mixed' that provides the data presented in the resulting flextable. You can remove significance stars by setting options \code{options(show.signif.stars = FALSE)}. } \examples{ if (require("broom.mixed") && require("nlme")) { m1 <- lme(distance ~ age, data = Orthodont) ft <- as_flextable(m1) ft } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/get_flextable_defaults.Rd0000644000176200001440000000155214310450150017752 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/defaults.R \name{get_flextable_defaults} \alias{get_flextable_defaults} \title{Get flextable defaults formatting properties} \usage{ get_flextable_defaults() } \value{ a list containing default values. } \description{ The current formatting properties are automatically applied to every flextable you produce. These default values are returned by this function. } \examples{ get_flextable_defaults() } \seealso{ Other functions related to themes: \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/hrule.Rd0000644000176200001440000000273314364612403014411 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{hrule} \alias{hrule} \title{Set flextable rule for rows heights} \usage{ hrule(x, i = NULL, rule = "auto", part = "body") } \arguments{ \item{x}{flextable object} \item{i}{rows selection} \item{rule}{specify the meaning of the height. Possible values are "atleast" (height should be at least the value specified), "exact" (height should be exactly the value specified), or the default value "auto" (height is determined based on the height of the contents, so the value is ignored).} \item{part}{partname of the table, one of "all", "header", "body", "footer"} } \description{ control rules of each height for a part of the flextable, this is only for Word and PowerPoint outputs, it will not have any effect when output is HTML or PDF. For PDF see the \code{ft.arraystretch} chunk option. } \examples{ ft_1 <- flextable(head(iris)) ft_1 <- width(ft_1, width = 1.5) ft_1 <- height(ft_1, height = 0.75, part = "header") ft_1 <- hrule(ft_1, rule = "exact", part = "header") ft_1 ft_2 <- hrule(ft_1, rule = "auto", part = "header") ft_2 } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/colformat_char.Rd0000644000176200001440000000206414402205763016252 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_char} \alias{colformat_char} \title{Format character cells} \usage{ colformat_char( x, i = NULL, j = NULL, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format character cells in a flextable. } \examples{ dat <- iris z <- flextable(head(dat)) ft <- colformat_char( x = z, j = "Species", suffix = "!" ) z <- autofit(z) z } \seealso{ Other cells formatters: \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/save_as_rtf.Rd0000644000176200001440000000362314515040463015564 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{save_as_rtf} \alias{save_as_rtf} \title{Save flextable objects in an 'RTF' file} \usage{ save_as_rtf(..., values = NULL, path, pr_section = NULL) } \arguments{ \item{...}{flextable objects, objects, possibly named. If named objects, names are used as titles.} \item{values}{a list (possibly named), each element is a flextable object. If named objects, names are used as titles. If provided, argument \code{...} will be ignored.} \item{path}{Word file to be created} \item{pr_section}{a \link{prop_section} object that can be used to define page layout such as orientation, width and height.} } \value{ a string containing the full name of the generated file } \description{ sugar function to save flextable objects in an 'RTF' file. } \examples{ tf <- tempfile(fileext = ".rtf") library(officer) ft1 <- flextable(head(iris)) save_as_rtf(ft1, path = tf) ft2 <- flextable(head(mtcars)) sect_properties <- prop_section( page_size = page_size( orient = "landscape", width = 8.3, height = 11.7 ), type = "continuous", page_margins = page_mar(), header_default = block_list( fpar(ftext("text for default page header")), qflextable(data.frame(a = 1L)) ) ) tf <- tempfile(fileext = ".rtf") save_as_rtf( `iris table` = ft1, `mtcars table` = ft2, path = tf, pr_section = sect_properties ) } \seealso{ \code{\link[=paginate]{paginate()}} Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/padding.Rd0000644000176200001440000000323214411071536014672 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{padding} \alias{padding} \title{Set paragraph paddings} \usage{ padding( x, i = NULL, j = NULL, padding = NULL, padding.top = NULL, padding.bottom = NULL, padding.left = NULL, padding.right = NULL, part = "body" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{padding}{padding (shortcut for top, bottom, left and right), unit is pts (points).} \item{padding.top}{padding top, unit is pts (points).} \item{padding.bottom}{padding bottom, unit is pts (points).} \item{padding.left}{padding left, unit is pts (points).} \item{padding.right}{padding right, unit is pts (points).} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change paddings of selected rows and columns of a flextable. } \examples{ ft_1 <- flextable(head(iris)) ft_1 <- theme_vader(ft_1) ft_1 <- padding(ft_1, padding.top = 4, part = "all") ft_1 <- padding(ft_1, j = 1, padding.right = 40) ft_1 <- padding(ft_1, i = 3, padding.top = 40) ft_1 <- padding(ft_1, padding.top = 10, part = "header") ft_1 <- padding(ft_1, padding.bottom = 10, part = "header") ft_1 <- autofit(ft_1) ft_1 } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/vline_left.Rd0000644000176200001440000000235214476430471015425 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{vline_left} \alias{vline_left} \title{Set flextable left vertical borders} \usage{ vline_left(x, i = NULL, border = NULL, part = "all") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying vertical borders to the left side of one or all parts of a flextable. The line is the left border of selected cells of the first column. } \examples{ library(officer) std_border <- fp_border(color = "orange") ft <- flextable(head(iris)) ft <- border_remove(x = ft) # add vertical border on the left side of the table ft <- vline_left(ft, border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/as_flextable.summarizor.Rd0000644000176200001440000000263714476430471020144 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{as_flextable.summarizor} \alias{as_flextable.summarizor} \title{Transform a 'summarizor' object into a flextable} \usage{ \method{as_flextable}{summarizor}(x, ...) } \arguments{ \item{x}{result from \code{\link[=summarizor]{summarizor()}}} \item{...}{arguments for \code{\link[=as_flextable.tabulator]{as_flextable.tabulator()}}} } \description{ \code{summarizor} object should be transformed into a flextable with method \code{\link[=as_flextable]{as_flextable()}}. } \examples{ \dontshow{ data.table::setDTthreads(1) } z <- summarizor(CO2[-c(1, 4)], by = "Treatment", overall_label = "Overall" ) ft_1 <- as_flextable(z, spread_first_col = TRUE) ft_1 <- prepend_chunks(ft_1, i = ~ is.na(variable), j = 1, as_chunk("\t") ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/headers_flextable_at_bkm.Rd0000644000176200001440000000136314432120335020240 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/body_add_flextable.R \name{headers_flextable_at_bkm} \alias{headers_flextable_at_bkm} \title{Add flextable at a bookmark location in document's header} \usage{ headers_flextable_at_bkm(x, bookmark, value) } \arguments{ \item{x}{an rdocx object} \item{bookmark}{bookmark id} \item{value}{a flextable object} } \description{ replace in the header of a document a paragraph containing a bookmark by a flextable. A bookmark will be considered as valid if enclosing words within a paragraph; i.e., a bookmark along two or more paragraphs is invalid, a bookmark set on a whole paragraph is also invalid, but bookmarking few words inside a paragraph is valid. } \keyword{internal} flextable/man/hline.Rd0000644000176200001440000000233414476430471014375 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{hline} \alias{hline} \title{Set horizontal borders} \usage{ hline(x, i = NULL, j = NULL, border = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying an horizontal border to inner content of one or all parts of a flextable. The lines are the bottom borders of selected cells. } \examples{ library(officer) std_border <- fp_border(color = "gray") ft <- flextable(head(iris)) ft <- border_remove(x = ft) # add horizontal borders ft <- hline(ft, part = "all", border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/minibar.Rd0000644000176200001440000000355014476430471014720 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{minibar} \alias{minibar} \title{Mini barplots chunk wrapper} \usage{ minibar( value, max = NULL, barcol = "#CCCCCC", bg = "transparent", width = 1, height = 0.2, unit = "in" ) } \arguments{ \item{value}{values containing the bar size} \item{max}{max bar size} \item{barcol}{bar color} \item{bg}{background color} \item{width, height}{size of the resulting png file in inches} \item{unit}{unit for width and height, one of "in", "cm", "mm".} } \description{ This function is used to insert bars into flextable with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}}. } } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ ft <- flextable(head(iris, n = 10)) ft <- compose(ft, j = 1, value = as_paragraph( minibar(value = Sepal.Length, max = max(Sepal.Length)) ), part = "body" ) ft <- autofit(ft) ft } \seealso{ \code{\link[=compose]{compose()}}, \code{\link[=as_paragraph]{as_paragraph()}} Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/as_flextable.tabular.Rd0000644000176200001440000000777314437711574017377 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.tabular.R \name{as_flextable.tabular} \alias{as_flextable.tabular} \title{Transform a 'tables::tabular' object into a flextable} \usage{ \method{as_flextable}{tabular}( x, spread_first_col = FALSE, fp_p = fp_par(text.align = "center", padding.top = 4), row_title = as_paragraph(as_chunk(.row_title)), add_tab = FALSE, ... ) } \arguments{ \item{x}{object produced by \code{\link[tables:tabular]{tables::tabular()}}.} \item{spread_first_col}{if TRUE, first row is spread as a new line separator instead of being a column. This helps to reduce the width and allows for clear divisions.} \item{fp_p}{paragraph formatting properties associated with row titles, see \code{\link[=fp_par]{fp_par()}}.} \item{row_title}{a call to \code{\link[=as_paragraph]{as_paragraph()}} - it will be applied to the row titles if any when \code{spread_first_col=TRUE}.} \item{add_tab}{adds a tab in front of "list_data" label lines (located in column \code{.type}).} \item{...}{unused argument} } \description{ Produce a flextable from a 'tabular' object produced with function \code{\link[tables:tabular]{tables::tabular()}}. When \code{as_flextable.tabular=TRUE}, the first column is used as row separator acting as a row title. It can be formated with arguments \code{fp_p} (the formatting properties of the paragraph) and \code{row_title} that specifies the content and eventually formattings of the content. Two hidden columns can be used for conditional formatting after the creation of the flextable (use only when \code{spread_first_col=TRUE}): \itemize{ \item The column \code{.row_title} that contains the title label \item The column \code{.type} that can contain the following values: \itemize{ \item "one_row": Indicates that there is only one row for this group. In this case, the row is not expanded with a title above. \item "list_title": Indicates a row that serves as a title for the data that are displayed after it. \item "list_data": Indicates rows that follow a title and contain data to be displayed. } } The result is paginated (see \code{\link[=paginate]{paginate()}}). } \examples{ if (require("tables")) { set.seed(42) genders <- c("Male", "Female") status <- c("low", "medium", "high") Sex <- factor(sample(genders, 100, rep = TRUE)) Status <- factor(sample(status, 100, rep = TRUE)) z <- rnorm(100) + 5 fmt <- function(x) { s <- format(x, digits = 2) even <- ((1:length(s)) \%\% 2) == 0 s[even] <- sprintf("(\%s)", s[even]) s } tab <- tabular( Justify(c) * Heading() * z * Sex * Heading(Statistic) * Format(fmt()) * (mean + sd) ~ Status ) as_flextable(tab) } if (require("tables")) { tab <- tabular( (Species + 1) ~ (n = 1) + Format(digits = 2) * (Sepal.Length + Sepal.Width) * (mean + sd), data = iris ) as_flextable(tab) } if (require("tables")) { x <- tabular((Factor(gear, "Gears") + 1) * ((n = 1) + Percent() + (RowPct = Percent("row")) + (ColPct = Percent("col"))) ~ (Factor(carb, "Carburetors") + 1) * Format(digits = 1), data = mtcars) ft <- as_flextable( x, spread_first_col = TRUE, row_title = as_paragraph( colorize("Gears: ", color = "#666666"), colorize(as_b(.row_title), color = "red") ) ) ft } if (require("tables")) { tab <- tabular( (mean + mean) * (Sepal.Length + Sepal.Width) ~ 1, data = iris ) as_flextable(tab) } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/summarizor.Rd0000644000176200001440000000304214476430471015503 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{summarizor} \alias{summarizor} \title{Data summary preparation} \usage{ summarizor( x, by = character(), overall_label = NULL, num_stats = c("mean_sd", "median_iqr", "range"), hide_null_na = TRUE ) } \arguments{ \item{x}{dataset} \item{by}{columns names to be used as grouping columns} \item{overall_label}{label to use as overall label} \item{num_stats}{available statistics for numerical columns to show, available options are "mean_sd", "median_iqr" and "range".} \item{hide_null_na}{if TRUE (default), NA counts will not be shown when 0.} } \description{ It performs a univariate statistical analysis of a dataset by group and formats the results so that they can be used with the \code{\link[=tabulator]{tabulator()}} function or directly with \link[=as_flextable.summarizor]{as_flextable}. \if{html}{\out{ summarizor illustration }} } \note{ This is very first version of the function; be aware it can evolve or change. } \examples{ \dontshow{ data.table::setDTthreads(1) } z <- summarizor(CO2[-c(1, 4)], by = "Treatment", overall_label = "Overall" ) ft_1 <- as_flextable(z) ft_1 ft_2 <- as_flextable(z, sep_w = 0, spread_first_col = TRUE) ft_2 z <- summarizor(CO2[-c(1, 4)]) ft_3 <- as_flextable(z, sep_w = 0, spread_first_col = TRUE) ft_3 } \seealso{ \code{\link[=fmt_summarizor]{fmt_summarizor()}}, \code{\link[=labelizor]{labelizor()}} } flextable/man/theme_vader.Rd0000644000176200001440000000376014364612403015556 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_vader} \alias{theme_vader} \title{Apply Sith Lord Darth Vader theme} \usage{ theme_vader(x, ...) } \arguments{ \item{x}{a flextable object} \item{...}{unused} } \description{ Apply Sith Lord Darth Vader theme to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_vader(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/grid_chunk.Rd0000644000176200001440000000353614476430471015420 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{grid_chunk} \alias{grid_chunk} \title{'Grid Graphics' chunk wrapper} \usage{ grid_chunk(value, width = 1, height = 0.2, unit = "in", res = 300) } \arguments{ \item{value}{grid objects, stored in a list column; or a list of grid objects.} \item{width, height}{size of the resulting png file} \item{unit}{unit for width and height, one of "in", "cm", "mm".} \item{res}{resolution of the png image in ppi} } \description{ This function is used to insert grid objects into flextable with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}}. } } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ library(flextable) ft_1 <- flextable(head(cars)) if (require("grid")) { ft_1 <- prepend_chunks( x = ft_1, i = 2, j = 2, grid_chunk( list( circleGrob(gp = gpar( fill = "#ec11c2", col = "transparent" )) ), width = .15, height = .15 ) ) } ft_1 } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/bg.Rd0000644000176200001440000000444414411071536013662 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{bg} \alias{bg} \title{Set background color} \usage{ bg(x, i = NULL, j = NULL, bg, part = "body", source = j) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{bg}{color to use as background color. If a function, function need to return a character vector of colors.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} \item{source}{if bg is a function, source is specifying the dataset column to be used as argument to \code{bg}. This is only useful if j is colored with values contained in other columns.} } \description{ Change background color of selected rows and columns of a flextable. A function can be used instead of fixed colors. When \code{bg} is a function, it is possible to color cells based on values located in other columns, using hidden columns (those not used by argument \code{colkeys}) is a common use case. The argument \code{source} has to be used to define what are the columns to be used for the color definition and the argument \code{j} has to be used to define where to apply the colors and only accept values from \code{colkeys}. } \note{ Word does not allow you to apply transparency to table cells or paragraph shading. } \examples{ ft_1 <- flextable(head(mtcars)) ft_1 <- bg(ft_1, bg = "wheat", part = "header") ft_1 <- bg(ft_1, i = ~ qsec < 18, bg = "#EFEFEF", part = "body") ft_1 <- bg(ft_1, j = "drat", bg = "#606060", part = "all") ft_1 <- color(ft_1, j = "drat", color = "white", part = "all") ft_1 if (require("scales")) { ft_2 <- flextable(head(iris)) colourer <- col_numeric( palette = c("wheat", "red"), domain = c(0, 7) ) ft_2 <- bg(ft_2, j = c( "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width" ), bg = colourer, part = "body" ) ft_2 } } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/width.Rd0000644000176200001440000000240614364612403014406 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{width} \alias{width} \title{Set columns width} \usage{ width(x, j = NULL, width, unit = "in") } \arguments{ \item{x}{a \code{\link[=flextable]{flextable()}} object} \item{j}{columns selection} \item{width}{width in inches} \item{unit}{unit for width, one of "in", "cm", "mm".} } \description{ Defines the widths of one or more columns in the table. This function will have no effect if you have used \code{set_table_properties(layout = "autofit")}. \code{\link[=set_table_properties]{set_table_properties()}} can provide an alternative to fixed-width layouts that is supported with HTML and Word output that can be set with \code{set_table_properties(layout = "autofit")}. } \details{ Heights are not used when flextable is been rendered into HTML. } \examples{ ft <- flextable(head(iris)) ft <- width(ft, width = 1.5) ft } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()} } \concept{flextable dimensions} flextable/man/fmt_header_n.Rd0000644000176200001440000000171514476430471015713 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_header_n} \alias{fmt_header_n} \title{Format count data for headers} \usage{ fmt_header_n(n, newline = TRUE) } \arguments{ \item{n}{count values} \item{newline}{indicates to prefix the text with a new line (sof return).} } \description{ The function formats counts as \verb{\\n(N=XX)}. This helper function is used to add counts in columns titles. } \examples{ library(flextable) df <- data.frame(zz = 1) ft_1 <- flextable(df) ft_1 <- append_chunks( x = ft_1, j = 1, part = "header", value = as_chunk(fmt_header_n(200)) ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_2stats}()}, \code{\link{fmt_avg_dev}()}, \code{\link{fmt_dbl}()}, \code{\link{fmt_int}()}, \code{\link{fmt_n_percent}()}, \code{\link{fmt_pct}()} } \concept{text formatter functions} flextable/man/flextable_dim.Rd0000644000176200001440000000200114375476120016063 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{flextable_dim} \alias{flextable_dim} \title{Get width and height of a flextable object} \usage{ flextable_dim(x, unit = "in") } \arguments{ \item{x}{a flextable object} \item{unit}{unit for returned values, one of "in", "cm", "mm".} } \description{ Returns the width, height and aspect ratio of a flextable in a named list. The aspect ratio is the ratio corresponding to \code{height/width}. Names of the list are \code{width}, \code{height} and \code{aspect_ratio}. } \examples{ ftab <- flextable(head(iris)) flextable_dim(ftab) ftab <- autofit(ftab) flextable_dim(ftab) } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/set_header_labels.Rd0000644000176200001440000000327514515157112016720 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{set_header_labels} \alias{set_header_labels} \title{Change headers labels} \usage{ set_header_labels(x, ..., values = NULL) } \arguments{ \item{x}{a \code{flextable} object} \item{...}{named arguments (names are data colnames), each element is a single character value specifying label to use.} \item{values}{a named list (names are data colnames), each element is a single character value specifying label to use. If provided, argument \code{...} will be ignored. It can also be a unamed character vector, in that case, it must have the same length than the number of columns of the flextable.} } \description{ This function set labels for specified columns in the bottom row header of a flextable. } \examples{ ft <- flextable(head(iris)) ft <- set_header_labels(ft, Sepal.Length = "Sepal length", Sepal.Width = "Sepal width", Petal.Length = "Petal length", Petal.Width = "Petal width" ) ft <- flextable(head(iris)) ft <- set_header_labels(ft, values = list( Sepal.Length = "Sepal length", Sepal.Width = "Sepal width", Petal.Length = "Petal length", Petal.Width = "Petal width" ) ) ft } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}} } \concept{functions for row and column operations in a flextable} flextable/man/nrow_part.Rd0000644000176200001440000000146014021743006015273 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/nrowcol.R \name{nrow_part} \alias{nrow_part} \title{Number of rows of a part} \usage{ nrow_part(x, part = "body") } \arguments{ \item{x}{flextable object} \item{part}{partname of the table (one of 'body', 'header', 'footer')} } \description{ returns the number of lines in a part of flextable. } \examples{ library(flextable) ft <- qflextable(head(cars)) nrow_part(ft, part = "body") } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/set_caption.Rd0000644000176200001440000002313514476430471015610 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable.R \name{set_caption} \alias{set_caption} \title{Set Caption} \usage{ set_caption( x, caption = NULL, autonum = NULL, word_stylename = "Table Caption", style = word_stylename, fp_p = fp_par(padding = 3), align_with_table = TRUE, html_classes = NULL, html_escape = TRUE ) } \arguments{ \item{x}{flextable object} \item{caption}{caption value. The caption can be either a string either a call to \code{\link[=as_paragraph]{as_paragraph()}}. In the latter case, users are free to format the caption with colors, italic fonts, also mixed with images or equations. Note that Quarto does not allow the use of this feature. Caption as a string does not support 'Markdown' syntax. If you want to add a bold text in the caption, use \code{as_paragraph('a ', as_b('bold'), ' text')} when providing caption.} \item{autonum}{an autonum representation. See \code{\link[officer:run_autonum]{officer::run_autonum()}}. This has an effect only when the output is "Word" (in which case the object is used to define the Word auto-numbering), "html" and "pdf" (in which case only the bookmark identifier will be used). If used, the caption is preceded by an auto-number sequence.} \item{word_stylename, style}{'Word' style name to associate with caption paragraph. These names are available with function \code{\link[officer:styles_info]{officer::styles_info()}} when output is Word. Argument \code{style} is deprecated in favor of \code{word_stylename}. If the caption is defined with \code{as_paragraph()}, some of the formattings of the paragraph style will be replaced by the formattings associated with the chunks (such as the font).} \item{fp_p}{paragraph formatting properties associated with the caption, see \code{\link[=fp_par]{fp_par()}}. It applies when possible, i.e. in HTML and 'Word' but not with bookdown.} \item{align_with_table}{if TRUE, caption is aligned as the flextable, if FALSE, \code{fp_p} will not be updated and alignement is as defined with \code{fp_p}. It applies when possible, i.e. in HTML and 'Word' but not with bookdown.} \item{html_classes}{css class(es) to apply to associate with caption paragraph when output is 'Word'.} \item{html_escape}{should HTML entities be escaped so that it can be safely included as text or an attribute value within an HTML document.} } \description{ Set caption value in a flextable. The function can also be used to define formattings that will be applied if possible to Word and HTML outputs. \itemize{ \item The caption will be associated with a paragraph style when the output is Word. It can also be numbered as a auto-numbered Word computed value. \item The PowerPoint format ignores captions. PowerPoint documents are not structured and do not behave as HTML documents and paginated documents (word, pdf), and it's not possible to know where we should create a shape to contain the caption (technically it can't be in the PowerPoint shape containing the table). } When working with 'R Markdown' or 'Quarto', the caption settings defined with \code{set_caption()} will be prioritized over knitr chunk options. Caption value can be a single string or the result to a call to \code{\link[=as_paragraph]{as_paragraph()}}. With the latter, the caption is made of formatted chunks whereas with the former, caption will not be associated with any formatting. } \details{ The behavior of captions in the 'flextable' package varies depending on the formats and technologies used. The values set by the \code{set_caption()} function will be prioritized whenever possible, including the caption ID and associated paragraph style. However, it's important to note that the behavior may differ across different tools. Here's what we have observed and attempted to respect, but please inform us if you believe our observations are incorrect: \itemize{ \item In Word and HTML documents created with 'rmarkdown' \code{rmarkdown::word_document()} and \code{rmarkdown::html_document()}, numbered and cross-referenced captions are not typically expected. \item In PDF documents created with 'rmarkdown' \code{rmarkdown::pdf_document()}, numbers are automatically added before the caption. \item In Word and HTML documents created with 'bookdown', numbered and cross-referenced captions are expected. 'bookdown' handles this functionality, but due to technical reasons, the caption should not be defined within an HTML or XML block. Therefore, when using 'flextable', the ability to format the caption content is lost (this limitation does not apply to PDF documents). \item HTML and PDF documents created with Quarto handle captions and cross-references differently. Quarto replaces captions with 'tbl-cap' and 'label' values. \item Word documents created with Quarto present another specific case. Currently, Quarto does not inject captions using the 'tbl-cap' and label values. However, this is a temporary situation that is expected to change in the future. The 'flextable' package will adapt accordingly as Quarto evolves. \item When using the \code{body_add_flextable()} function, all the options specified with \code{set_caption()} will be enabled. } Using \code{\link[=body_add_flextable]{body_add_flextable()}} enable all options specified with \code{set_caption()}. } \section{R Markdown}{ flextable captions can be defined from R Markdown documents by using \code{knitr::opts_chunk$set()}. User don't always have to call \code{set_caption()} to set a caption, he can use knitr chunk options instead. A typical call would be: \if{html}{\out{
}}\preformatted{```\{r\} #| tab.id: bookmark_id #| tab.cap: caption text flextable(head(cars)) ``` }\if{html}{\out{
}} \code{tab.id} is the caption id or bookmark, \code{tab.cap} is the caption text. There are many options that can replace \code{set_caption()} features. The following knitr chunk options are available:\tabular{lcc}{ \strong{label} \tab \strong{name} \tab \strong{value} \cr Word stylename to use for table captions. \tab tab.cap.style \tab NULL \cr caption id/bookmark \tab tab.id \tab NULL \cr caption \tab tab.cap \tab NULL \cr display table caption on top of the table or not \tab tab.topcaption \tab TRUE \cr caption table sequence identifier. \tab tab.lp \tab "tab:" \cr prefix for numbering chunk (default to "Table "). \tab tab.cap.pre \tab Table \cr suffix for numbering chunk (default to ": "). \tab tab.cap.sep \tab " :" \cr title number depth \tab tab.cap.tnd \tab 0 \cr separator to use between title number and table number. \tab tab.cap.tns \tab "-" \cr caption prefix formatting properties \tab tab.cap.fp_text \tab fp_text_lite(bold = TRUE) \cr } See \link{knit_print.flextable} for more details. } \section{Formatting the caption}{ To create captions in R Markdown using the 'flextable' package and 'officer' package, you can utilize the \code{as_paragraph()} function. This approach is recommended when your captions require complex content, such as a combination of different text styles or the inclusion of images and equations. The caption is constructed as a paragraph consisting of multiple chunks. Each chunk represents a specific portion of the caption with its desired formatting, such as red bold text or Arial italic text. By default, if no specific formatting is specified (using either "a string" or \code{as_chunk("a string")}), the \code{fp_text_default()} function sets the font settings for the caption, including the font family, boldness, italics, color, etc. The default values can be modified using the \code{set_flextable_defaults()} function. However, it is recommended to explicitly use \code{as_chunk()} to define the desired formatting. It's important to note that the style properties of the caption will not override the formatting of the individual elements within it. Therefore, you need to explicitly specify the font to be used for the caption. Here's an example of how to set a caption for a flextable in R Markdown using the 'officer' package: \if{html}{\out{
}}\preformatted{library(flextable) library(officer) ftab <- flextable(head(cars)) \%>\% set_caption( as_paragraph( as_chunk("caption", props = fp_text_default(font.family = "Cambria")) ), word_stylename = "Table Caption" ) print(ftab, preview = "docx") }\if{html}{\out{
}} In this example, the \code{set_caption()} function sets the caption for the flextable. The caption is created using \code{as_paragraph()} with a single chunk created using \code{as_chunk("caption", props = fp_text_default(font.family = "Cambria"))}. The \code{word_stylename} parameter is used to specify the table caption style in the resulting Word document. Finally, the \code{print()} function generates the flextable with the caption, and \code{preview = "docx"} displays a preview of the resulting Word document. } \section{Using 'Quarto'}{ In 'Quarto', captions and cross-references are handled differently compared to 'R Markdown', where flextable takes care of the job. In Quarto, the responsibility for managing captions lies with the Quarto framework itself. Consequently, the \code{set_caption()} function in 'flextable' is not as useful in a 'Quarto' document. The formatting and numbering of captions are determined by Quarto rather than flextable. Please refer to the Quarto documentation for more information on how to work with captions in Quarto. } \examples{ ftab <- flextable(head(iris)) ftab <- set_caption(ftab, "my caption") ftab library(officer) autonum <- run_autonum(seq_id = "tab", bkm = "mtcars") ftab <- flextable(head(mtcars)) ftab <- set_caption(ftab, caption = "mtcars data", autonum = autonum) ftab } \seealso{ \code{\link[=flextable]{flextable()}} } flextable/man/merge_v.Rd0000644000176200001440000000423414476430471014723 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/merge_flextable.R \name{merge_v} \alias{merge_v} \title{Merge flextable cells vertically} \usage{ merge_v(x, j = NULL, target = NULL, part = "body", combine = FALSE) } \arguments{ \item{x}{\code{flextable} object} \item{j}{column to used to find consecutive values to be merged. Columns from orignal dataset can also be used.} \item{target}{columns names where cells have to be merged.} \item{part}{partname of the table where merge has to be done.} \item{combine}{If the value is TRUE, the columns defined by \code{j} will be combined into a single column/value and the consecutive values of this result will be used. Otherwise, the columns are inspected one by one to perform cell merges.} } \description{ Merge flextable cells vertically when consecutive cells have identical values. Text of formatted values are used to compare values if available. Two options are available, either a column-by-column algorithm or an algorithm where the combinations of these columns are used once for all target columns. } \examples{ ft_merge <- flextable(mtcars) ft_merge <- merge_v(ft_merge, j = c("gear", "carb")) ft_merge data_ex <- structure(list(srdr_id = c( "175124", "175124", "172525", "172525", "172545", "172545", "172609", "172609", "172609" ), substances = c( "alcohol", "alcohol", "alcohol", "alcohol", "cannabis", "cannabis", "alcohol\n cannabis\n other drugs", "alcohol\n cannabis\n other drugs", "alcohol\n cannabis\n other drugs" ), full_name = c( "TAU", "MI", "TAU", "MI (parent)", "TAU", "MI", "TAU", "MI", "MI" ), article_arm_name = c( "Control", "WISEteens", "Treatment as usual", "Brief MI (b-MI)", "Assessed control", "Intervention", "Control", "Computer BI", "Therapist BI" )), row.names = c( NA, -9L ), class = c("tbl_df", "tbl", "data.frame")) ft_1 <- flextable(data_ex) ft_1 <- theme_box(ft_1) ft_2 <- merge_v(ft_1, j = "srdr_id", target = c("srdr_id", "substances") ) ft_2 } \seealso{ Other flextable merging function: \code{\link{merge_at}()}, \code{\link{merge_h_range}()}, \code{\link{merge_h}()}, \code{\link{merge_none}()} } \concept{flextable merging function} flextable/man/before.Rd0000644000176200001440000000213514476430471014537 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{before} \alias{before} \title{Is an element before a match with entries} \usage{ before(x, entries) } \arguments{ \item{x}{an atomic vector of values to be tested} \item{entries}{a sequence of items to be searched in \code{x}.} } \description{ return a logical vector of the same length as x, indicating if elements are located before a set of entries to match or not. } \examples{ library(flextable) library(officer) dat <- data.frame( stringsAsFactors = FALSE, check.names = FALSE, Level = c("setosa", "versicolor", "virginica", "", "Total"), Freq = as.integer(c(50, 50, 50, 0, 150)), `\% Valid` = c( 100 / 3, 100 / 3, 100 / 3, NA, 100 ), `\% Valid Cum.` = c(100 / 3, 100 * 2 / 3, 100, NA, 100), `\% Total` = c( 100 / 3, 100 / 3, 100 / 3, 0, 100 ), `\% Total Cum.` = c( 100 / 3, 100 * 2 / 3, 100, 100, 100 ) ) ft <- flextable(dat) ft <- hline(ft, i = ~ before(Level, "Total"), border = fp_border_default(width = 2) ) ft } \seealso{ \code{\link[=hline]{hline()}} } flextable/man/plot.flextable.Rd0000644000176200001440000000246714515040434016216 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{plot.flextable} \alias{plot.flextable} \title{Plot a flextable} \usage{ \method{plot}{flextable}(x, ...) } \arguments{ \item{x}{a flextable object} \item{...}{additional arguments passed to \code{\link[=gen_grob]{gen_grob()}}.} } \description{ plots a flextable as a grid grob object and display the result in a new graphics window. 'ragg' or 'svglite' or 'ggiraph' graphical device drivers should be used to ensure a correct rendering. } \examples{ library(gdtools) library(ragg) register_liberationsans() set_flextable_defaults(font.family = "Liberation Sans") ftab <- as_flextable(cars) tf <- tempfile(fileext = ".png") agg_png( filename = tf, width = 1.7, height = 3.26, unit = "in", background = "transparent", res = 150 ) plot(ftab) dev.off() } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/fit_to_width.Rd0000644000176200001440000000205214470463166015757 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{fit_to_width} \alias{fit_to_width} \title{Fit a flextable to a maximum width} \usage{ fit_to_width(x, max_width, inc = 1L, max_iter = 20, unit = "in") } \arguments{ \item{x}{flextable object} \item{max_width}{maximum width to fit in inches} \item{inc}{the font size decrease for each step} \item{max_iter}{maximum iterations} \item{unit}{unit for max_width, one of "in", "cm", "mm".} } \description{ decrease font size for each cell incrementally until it fits a given max_width. } \examples{ ft_1 <- qflextable(head(mtcars)) ft_1 <- width(ft_1, width = 1) ft_1 ft_2 <- fit_to_width(ft_1, max_width = 4) ft_2 } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/chunk_dataframe.Rd0000644000176200001440000000444314375473105016414 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{chunk_dataframe} \alias{chunk_dataframe} \title{Create a chunk representation suitable for flextable} \usage{ chunk_dataframe(...) } \arguments{ \item{...}{values to set.} } \value{ a data.frame with an additional class "chunk" that makes it suitable for beeing used in \code{\link[=as_paragraph]{as_paragraph()}} } \description{ This function is to be used by external packages that want to provide an object that can be inserted as a chunk object in paragraphs of a flextable object. } \section{text pattern with default values}{ \if{html}{\out{
}}\preformatted{chunk_dataframe(txt = c("any text", "other text")) }\if{html}{\out{
}} } \section{text pattern with bold set to TRUE}{ \if{html}{\out{
}}\preformatted{chunk_dataframe( txt = c("any text", "other text"), bold = c(TRUE, TRUE)) }\if{html}{\out{
}} } \section{text pattern with control over all formatting properties}{ \if{html}{\out{
}}\preformatted{chunk_dataframe( txt = c("any text", "other text"), font.size = c(12, 10), italic = c(FALSE, TRUE), bold = c(FALSE, TRUE), underlined = c(FALSE, TRUE), color = c("black", "red"), shading.color = c("transparent", "yellow"), font.family = c("Arial", "Arial"), hansi.family = c("Arial", "Arial"), eastasia.family = c("Arial", "Arial"), cs.family = c("Arial", "Arial"), vertical.align = c("top", "bottom") ) }\if{html}{\out{
}} } \section{text with url pattern}{ \if{html}{\out{
}}\preformatted{chunk_dataframe( txt = c("any text", "other text"), url = rep("https://www.google.fr", 2), font.size = c(12, 10), italic = c(FALSE, TRUE), bold = c(FALSE, TRUE), underlined = c(FALSE, TRUE), color = c("black", "red"), shading.color = c("transparent", "yellow"), font.family = c("Arial", "Arial"), hansi.family = c("Arial", "Arial"), eastasia.family = c("Arial", "Arial"), cs.family = c("Arial", "Arial"), vertical.align = c("top", "bottom") ) }\if{html}{\out{
}} } \section{images pattern}{ \if{html}{\out{
}}\preformatted{chunk_dataframe(width = width, height = height, img_data = files ) }\if{html}{\out{
}} } \keyword{internal} flextable/man/colformat_int.Rd0000644000176200001440000000222114375473105016130 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_int} \alias{colformat_int} \title{Format integer cells} \usage{ colformat_int( x, i = NULL, j = NULL, big.mark = get_flextable_defaults()$big.mark, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{big.mark}{see \code{\link[=format]{format()}}} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format integer cells in a flextable. } \examples{ z <- flextable(head(mtcars)) j <- c("vs", "am", "gear", "carb") z <- colformat_int(x = z, j = j, prefix = "# ") z } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/bold.Rd0000644000176200001440000000174214411071536014210 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{bold} \alias{bold} \title{Set bold font} \usage{ bold(x, i = NULL, j = NULL, bold = TRUE, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{bold}{boolean value} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change font weight of selected rows and columns of a flextable. } \examples{ ft <- flextable(head(iris)) ft <- bold(ft, bold = TRUE, part = "header") } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/as_raster.Rd0000644000176200001440000000250614515040434015250 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{as_raster} \alias{as_raster} \title{Transform a flextable into a raster} \usage{ as_raster(x, ...) } \arguments{ \item{x}{a flextable object} \item{...}{additional arguments passed to other functions} } \description{ save a flextable as an image and return the corresponding raster. This function has been implemented to let flextable be printed on a ggplot object. The function is no longer very useful since \code{\link[=gen_grob]{gen_grob()}} exists and will be deprecated in a future version. } \note{ This function requires package 'magick'. } \examples{ ft <- qflextable(head(mtcars)) \dontrun{ if (require("ggplot2") && require("magick")) { print(qplot(speed, dist, data = cars, geom = "point")) grid::grid.raster(as_raster(ft)) } } } \seealso{ Other flextable print function: \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} \keyword{internal} flextable/man/fmt_pct.Rd0000644000176200001440000000150314476430471014727 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_pct} \alias{fmt_pct} \title{Format numerical data as percentages} \usage{ fmt_pct(x) } \arguments{ \item{x}{numeric values} } \description{ The function formats numeric vectors as percentages. } \examples{ library(flextable) df <- data.frame(zz = .45) ft_1 <- flextable(df) ft_1 <- mk_par( x = ft_1, j = 1, part = "body", value = as_paragraph(as_chunk(zz, formatter = fmt_pct)) ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_2stats}()}, \code{\link{fmt_avg_dev}()}, \code{\link{fmt_dbl}()}, \code{\link{fmt_header_n}()}, \code{\link{fmt_int}()}, \code{\link{fmt_n_percent}()} } \concept{text formatter functions} flextable/man/as_flextable.tabulator.Rd0000644000176200001440000000704014476430470017721 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable_tabulator.R \name{as_flextable.tabulator} \alias{as_flextable.tabulator} \title{Transform a 'tabulator' object into a flextable} \usage{ \method{as_flextable}{tabulator}( x, separate_with = character(0), big_border = fp_border_default(width = 1.5), small_border = fp_border_default(width = 0.75), rows_alignment = "left", columns_alignment = "center", label_rows = x$rows, spread_first_col = FALSE, expand_single = FALSE, sep_w = 0.05, unit = "in", ... ) } \arguments{ \item{x}{result from \code{\link[=tabulator]{tabulator()}}} \item{separate_with}{columns used to sepatate the groups with an horizontal line.} \item{big_border, small_border}{big and small border properties defined by a call to \code{\link[=fp_border_default]{fp_border_default()}} or \code{\link[=fp_border]{fp_border()}}.} \item{rows_alignment, columns_alignment}{alignments to apply to columns corresponding to \code{rows} and \code{columns}; see arguments \code{rows} and \code{columns} in \code{\link[=tabulator]{tabulator()}}.} \item{label_rows}{labels to use for the first column names, i.e. the \emph{row} column names. It must be a named vector, the values will be matched based on the names.} \item{spread_first_col}{if TRUE, first row is spread as a new line separator instead of being a column. This helps to reduce the width and allows for clear divisions.} \item{expand_single}{if FALSE (the default), groups with only one row will not be expanded with a title row. If TRUE, single row groups and multi-row groups are all restructured.} \item{sep_w}{blank column separators'width to be used. If 0, blank column separators will not be used.} \item{unit}{unit of argument \code{sep_w}, one of "in", "cm", "mm".} \item{...}{unused argument} } \description{ \code{\link[=tabulator]{tabulator()}} object can be transformed as a flextable with method \code{\link[=as_flextable]{as_flextable()}}. } \examples{ \dontrun{ library(flextable) set_flextable_defaults(digits = 2, border.color = "gray") if (require("stats")) { dat <- aggregate(breaks ~ wool + tension, data = warpbreaks, mean ) cft_1 <- tabulator( x = dat, rows = "wool", columns = "tension", `mean` = as_paragraph(as_chunk(breaks)), `(N)` = as_paragraph( as_chunk(length(breaks)) ) ) ft_1 <- as_flextable(cft_1, sep_w = .1) ft_1 } if (require("stats")) { set_flextable_defaults( padding = 1, font.size = 9, border.color = "orange" ) ft_2 <- as_flextable(cft_1, sep_w = 0) ft_2 } if (require("stats")) { set_flextable_defaults( padding = 6, font.size = 11, border.color = "white", font.color = "white", background.color = "#333333" ) ft_3 <- as_flextable( x = cft_1, sep_w = 0, rows_alignment = "center", columns_alignment = "right" ) ft_3 } init_flextable_defaults() } } \seealso{ \code{\link[=summarizor]{summarizor()}}, \code{\link[=as_grouped_data]{as_grouped_data()}} Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/continuous_summary.Rd0000644000176200001440000000154014476430470017256 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{continuous_summary} \alias{continuous_summary} \title{Continuous columns summary} \usage{ continuous_summary( dat, columns = NULL, by = character(0), hide_grouplabel = TRUE, digits = 3 ) } \arguments{ \item{dat}{a data.frame} \item{columns}{continuous variables to be summarized. If NULL all continuous variables are summarized.} \item{by}{discrete variables to use as groups when summarizing.} \item{hide_grouplabel}{if TRUE, group label will not be rendered, only level/value will be rendered.} \item{digits}{the desired number of digits after the decimal point} } \description{ create a data.frame summary for continuous variables } \examples{ ft_1 <- continuous_summary(iris, names(iris)[1:4], by = "Species", hide_grouplabel = FALSE ) ft_1 } flextable/man/save_as_pptx.Rd0000644000176200001440000000334014515040463015760 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{save_as_pptx} \alias{save_as_pptx} \title{Save flextable objects in a 'PowerPoint' file} \usage{ save_as_pptx(..., values = NULL, path) } \arguments{ \item{...}{flextable objects, objects, possibly named. If named objects, names are used as slide titles.} \item{values}{a list (possibly named), each element is a flextable object. If named objects, names are used as slide titles. If provided, argument \code{...} will be ignored.} \item{path}{PowerPoint file to be created} } \value{ a string containing the full name of the generated file } \description{ sugar function to save flextable objects in an PowerPoint file. This feature is available to simplify the work of users by avoiding the need to use the 'officer' package. If it doesn't suit your needs, then use the API offered by 'officer' which allows simple and complicated things. } \note{ The PowerPoint format ignores captions (see \code{\link[=set_caption]{set_caption()}}). } \examples{ ft1 <- flextable(head(iris)) tf <- tempfile(fileext = ".pptx") save_as_pptx(ft1, path = tf) ft2 <- flextable(head(mtcars)) tf <- tempfile(fileext = ".pptx") save_as_pptx(`iris table` = ft1, `mtcars table` = ft2, path = tf) } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/compose.Rd0000644000176200001440000000501014476430471014735 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/compose.R \name{compose} \alias{compose} \alias{mk_par} \title{Define displayed values and mixed content} \usage{ compose(x, i = NULL, j = NULL, value, part = "body", use_dot = FALSE) mk_par(x, i = NULL, j = NULL, value, part = "body", use_dot = FALSE) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{column selection} \item{value}{a call to function \code{\link[=as_paragraph]{as_paragraph()}}.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} \item{use_dot}{by default \code{use_dot=FALSE}; if \code{use_dot=TRUE}, \code{value} is evaluated within a data.frame augmented of a column named \code{.} containing the \code{j}th column.} } \description{ Modify flextable displayed values with eventually mixed content paragraphs. Function is handling complex formatting as image insertion with \code{\link[=as_image]{as_image()}}, superscript with \code{\link[=as_sup]{as_sup()}}, formated text with \code{\link[=as_chunk]{as_chunk()}} and several other \emph{chunk} functions. Function \code{mk_par} is another name for \code{compose} as there is an unwanted \strong{conflict with package 'purrr'}. If you only need to add some content at the end or the beginning of paragraphs and keep existing content as it is, functions \code{\link[=append_chunks]{append_chunks()}} and \code{\link[=prepend_chunks]{prepend_chunks()}} should be prefered. } \examples{ ft_1 <- flextable(head(cars, n = 5), col_keys = c("speed", "dist", "comment")) ft_1 <- mk_par( x = ft_1, j = "comment", i = ~ dist > 9, value = as_paragraph( colorize(as_i("speed: "), color = "gray"), as_sup(sprintf("\%.0f", speed)) ) ) ft_1 <- set_table_properties(ft_1, layout = "autofit") ft_1 # using `use_dot = TRUE` ---- set.seed(8) dat <- iris[sample.int(n = 150, size = 10), ] dat <- dat[order(dat$Species), ] ft_2 <- flextable(dat) ft_2 <- mk_par(ft_2, j = ~ . - Species, value = as_paragraph( minibar(., barcol = "white", height = .1 ) ), use_dot = TRUE ) ft_2 <- theme_vader(ft_2) ft_2 <- autofit(ft_2) ft_2 } \seealso{ \code{\link[=fp_text_default]{fp_text_default()}}, \code{\link[=as_chunk]{as_chunk()}}, \code{\link[=as_b]{as_b()}}, \code{\link[=as_word_field]{as_word_field()}}, \code{\link[=labelizor]{labelizor()}} Other functions for mixed content paragraphs: \code{\link{append_chunks}()}, \code{\link{as_paragraph}()}, \code{\link{prepend_chunks}()} } \concept{functions for mixed content paragraphs} flextable/man/line_spacing.Rd0000644000176200001440000000220014411071536015711 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{line_spacing} \alias{line_spacing} \title{Set text alignment} \usage{ line_spacing(x, i = NULL, j = NULL, space = 1, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{space}{space between lines of text, 1 is single line spacing, 2 is double line spacing.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change text alignment of selected rows and columns of a flextable. } \examples{ ft <- flextable(head(mtcars)[, 3:6]) ft <- line_spacing(ft, space = 1.6, part = "all") ft <- set_table_properties(ft, layout = "autofit") ft } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/paginate.Rd0000644000176200001440000000574414476430471015076 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/paginate.R \name{paginate} \alias{paginate} \title{Paginate tables} \usage{ paginate( x, init = NULL, hdr_ftr = TRUE, group = character(), group_def = c("rle", "nonempty") ) } \arguments{ \item{x}{flextable object} \item{init}{init value for keep_with_next property, it default value is \code{get_flextable_defaults()$keep_with_next}.} \item{hdr_ftr}{if TRUE (default), prevent breaks between table body and header and between table body and footer.} \item{group}{name of a column to use for finding groups} \item{group_def}{algorithm to be used to identify groups that should not be split into two pages, one of 'rle', 'nonempty': \itemize{ \item 'rle': runs of equal values are used to define the groups, to be used with \code{\link[=tabulator]{tabulator()}}. \item 'nonempty': non empty value start a new group, to be used with \code{\link[=as_flextable.tabular]{as_flextable.tabular()}}. }} } \value{ updated flextable object } \description{ Prevents breaks between tables rows you want to stay together. This feature only applies to Word and RTF output. } \details{ The pagination of tables allows you to control their position in relation to page breaks. For small tables, a simple setting is usually used that indicates that all rows should be displayed together: \if{html}{\out{
}}\preformatted{paginate(x, init = TRUE, hdr_ftr = TRUE) }\if{html}{\out{
}} For large tables, it is recommended to use a setting that indicates that all rows of the header should be bound to the first row of the table to avoid the case where the header is displayed alone at the bottom of the page and then repeated on the next one: \if{html}{\out{
}}\preformatted{paginate(x, init = FALSE, hdr_ftr = TRUE) }\if{html}{\out{
}} For tables that present groups that you don't want to be presented on two pages, you must use a parameterization involving the notion of group and an algorithm for determining the groups. \if{html}{\out{
}}\preformatted{paginate(x, group = "grp", group_def = "rle") }\if{html}{\out{
}} } \examples{ \dontshow{ data.table::setDTthreads(1) } library(data.table) library(flextable) init_flextable_defaults() multi_fun <- function(x) { list(mean = mean(x), sd = sd(x)) } dat <- as.data.table(ggplot2::diamonds) dat <- dat[clarity \%in\% c("I1", "SI1", "VS2")] dat <- dat[, unlist(lapply(.SD, multi_fun), recursive = FALSE ), .SDcols = c("z", "y"), by = c("cut", "color", "clarity") ] tab <- tabulator( x = dat, rows = c("cut", "color"), columns = "clarity", `z stats` = as_paragraph(as_chunk(fmt_avg_dev(z.mean, z.sd, digit2 = 2))), `y stats` = as_paragraph(as_chunk(fmt_avg_dev(y.mean, y.sd, digit2 = 2))) ) ft_1 <- as_flextable(tab) ft_1 <- autofit(x = ft_1, add_w = .05) |> paginate(group = "cut", group_def = "rle") save_as_docx(ft_1, path = tempfile(fileext = ".docx")) save_as_rtf(ft_1, path = tempfile(fileext = ".rtf")) } flextable/man/add_footer_row.Rd0000644000176200001440000000543114515157112016264 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_footer_row} \alias{add_footer_row} \title{Add footer labels} \usage{ add_footer_row(x, top = TRUE, values = character(0), colwidths = integer(0)) } \arguments{ \item{x}{a flextable object} \item{top}{should the row be inserted at the top or the bottom.} \item{values}{values to add. It can be a \code{list}, a \code{character()} vector or a call to \code{\link[=as_paragraph]{as_paragraph()}}. If it is a list, it can be a named list with the names of the columns of the original data.frame or the \code{colkeys}; this is the recommended method because it allows to keep the original data types and therefore allows to perform conditional formatting. If a character, columns of the original data.frame stored in the flextable object are changed to \code{character()}; this is often not an issue with footer and header but can be inconvenient if adding rows into body as it will change data types to character and prevent efficient conditional formatting.} \item{colwidths}{the number of columns to merge in the row for each label} } \description{ Add a row of new columns labels in footer part. Labels can be spanned along multiple columns, as merged cells. Labels are associated with a number of columns to merge that default to one if not specified. In this case, you have to make sure that the number of labels is equal to the number of columns displayed. The function can add only one single row by call. Labels can be formatted with \code{\link[=as_paragraph]{as_paragraph()}}. } \examples{ library(flextable) ft01 <- fp_text_default(color = "red") ft02 <- fp_text_default(color = "orange") pars <- as_paragraph( as_chunk(c("(1)", "(2)"), props = ft02), " ", as_chunk( c( "My tailor is rich", "My baker is rich" ), props = ft01 ) ) ft_1 <- flextable(head(mtcars)) ft_1 <- add_footer_row(ft_1, values = pars, colwidths = c(5, 6), top = FALSE ) ft_1 <- add_footer_row(ft_1, values = pars, colwidths = c(3, 8), top = TRUE ) ft_1 ft_2 <- flextable(head(airquality)) ft_2 <- add_footer_row(ft_2, values = c("Measure", "Time"), colwidths = c(4, 2), top = TRUE ) ft_2 <- theme_box(ft_2) ft_2 } \seealso{ \code{\link[=flextable]{flextable()}}, \code{\link[=set_caption]{set_caption()}} Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/border_inner_h.Rd0000644000176200001440000000221314476430470016250 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{border_inner_h} \alias{border_inner_h} \title{Set inner borders} \usage{ border_inner_h(x, border = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying a border to inner content of one or all parts of a flextable. } \examples{ library(officer) std_border <- fp_border(color = "orange", width = 1) dat <- iris[c(1:5, 51:55, 101:105), ] ft <- flextable(dat) ft <- border_remove(x = ft) # add inner horizontal borders ft <- border_inner_h(ft, border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/delete_columns.Rd0000644000176200001440000000222714515157112016271 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{delete_columns} \alias{delete_columns} \title{Delete flextable columns} \usage{ delete_columns(x, j = NULL) } \arguments{ \item{x}{a \code{flextable} object} \item{j}{columns selection} } \description{ The function removes one or more columns from a 'flextable'. } \details{ Deleting one or more columns will result in the deletion of any span parameters that may have been set previously. They will have to be redone after this operation or performed only after this deletion. } \examples{ ft <- flextable(head(iris)) ft <- delete_columns(ft, j = "Species") ft } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/as_flextable.pam.Rd0000644000176200001440000000242114476430470016477 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.pam} \alias{as_flextable.pam} \title{Transform a 'pam' object into a flextable} \usage{ \method{as_flextable}{pam}(x, digits = 4, ...) } \arguments{ \item{x}{a \code{\link[cluster:pam]{cluster::pam()}} object} \item{digits}{number of digits for the numeric columns} \item{...}{unused argument} } \description{ produce a flextable describing a pam object. The function is only using package 'broom' that provides the data presented in the resulting flextable. } \examples{ if (require("cluster")) { dat <- as.data.frame(scale(mtcars[1:7])) cl <- pam(dat, 3) ft <- as_flextable(cl) ft } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/fmt_2stats.Rd0000644000176200001440000000520314476430471015362 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_2stats} \alias{fmt_2stats} \alias{fmt_summarizor} \title{Format content for data generated with summarizor()} \usage{ fmt_2stats( stat, num1, num2, cts, pcts, num1_mask = "\%.01f", num2_mask = "(\%.01f)", cts_mask = "\%.0f", pcts_mask = "(\%.02f\%\%)" ) fmt_summarizor( stat, num1, num2, cts, pcts, num1_mask = "\%.01f", num2_mask = "(\%.01f)", cts_mask = "\%.0f", pcts_mask = "(\%.02f\%\%)" ) } \arguments{ \item{stat}{a character column containing the name of statictics} \item{num1}{a numeric statistic to display such as a mean or a median} \item{num2}{a numeric statistic to display such as a standard deviation or a median absolute deviation.} \item{cts}{a count to display} \item{pcts}{a percentage to display} \item{num1_mask}{format associated with \code{num1}, a format string used by \code{\link[=sprintf]{sprintf()}}.} \item{num2_mask}{format associated with \code{num2}, a format string used by \code{\link[=sprintf]{sprintf()}}.} \item{cts_mask}{format associated with \code{cts}, a format string used by \code{\link[=sprintf]{sprintf()}}.} \item{pcts_mask}{format associated with \code{pcts}, a format string used by \code{\link[=sprintf]{sprintf()}}.} } \description{ This function was written to allow easy demonstrations of flextable's ability to produce table summaries (with \code{\link[=summarizor]{summarizor()}}). It assumes that we have either a quantitative variable, in which case we will display the mean and the standard deviation, or a qualitative variable, in which case we will display the count and the percentage corresponding to each modality. } \examples{ library(flextable) z <- summarizor(iris, by = "Species") tab_1 <- tabulator( x = z, rows = c("variable", "stat"), columns = "Species", blah = as_paragraph( as_chunk( fmt_summarizor( stat = stat, num1 = value1, num2 = value2, cts = cts, pcts = percent ) ) ) ) ft_1 <- as_flextable(x = tab_1, separate_with = "variable") ft_1 <- labelizor( x = ft_1, j = "stat", labels = c( mean_sd = "Moyenne (ecart-type)", median_iqr = "Mediane (IQR)", range = "Etendue", missing = "Valeurs manquantes" ) ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=summarizor]{summarizor()}}, \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_avg_dev}()}, \code{\link{fmt_dbl}()}, \code{\link{fmt_header_n}()}, \code{\link{fmt_int}()}, \code{\link{fmt_n_percent}()}, \code{\link{fmt_pct}()} } \concept{text formatter functions} flextable/man/border_outer.Rd0000644000176200001440000000220214476430470015762 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{border_outer} \alias{border_outer} \title{Set outer borders} \usage{ border_outer(x, border = NULL, part = "all") } \arguments{ \item{x}{a flextable object} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying a border to outer cells of one or all parts of a flextable. } \examples{ library(officer) big_border <- fp_border(color = "red", width = 2) dat <- iris[c(1:5, 51:55, 101:105), ] ft <- flextable(dat) ft <- border_remove(x = ft) # add outer borders ft <- border_outer(ft, part = "all", border = big_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/df_printer.Rd0000644000176200001440000000433714515040434015425 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/df_printer.R \name{df_printer} \alias{df_printer} \title{data.frame automatic printing as a flextable} \usage{ df_printer(dat, ...) } \arguments{ \item{dat}{the data.frame} \item{...}{unused argument} } \description{ Create a summary from a data.frame as a flextable. This function is to be used in an R Markdown document. To use that function, you must declare it in the part \code{df_print} of the 'YAML' header of your R Markdown document: \if{html}{\out{
}}\preformatted{--- df_print: !expr function(x) flextable::df_printer(x) --- }\if{html}{\out{
}} We notice an unexpected behavior with bookdown. When using bookdown it is necessary to use \code{\link[=use_df_printer]{use_df_printer()}} instead in a setup run chunk: \if{html}{\out{
}}\preformatted{use_df_printer() }\if{html}{\out{
}} } \details{ 'knitr' chunk options are available to customize the output: \itemize{ \item \code{ft_max_row}: The number of rows to print. Default to 10. \item \code{ft_split_colnames}: Should the column names be split (with non alpha-numeric characters). Default to FALSE. \item \code{ft_short_strings}: Should the character column be shorten. Default to FALSE. \item \code{ft_short_size}: Maximum length of character column if \code{ft_short_strings} is TRUE. Default to 35. \item \code{ft_short_suffix}: Suffix to add when character values are shorten. Default to "...". \item \code{ft_do_autofit}: Use autofit() before rendering the table. Default to TRUE. \item \code{ft_show_coltype}: Show column types. Default to TRUE. \item \code{ft_color_coltype}: Color to use for column types. Default to "#999999". } } \examples{ df_printer(head(mtcars)) } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/tabulator.Rd0000644000176200001440000001045014441705246015266 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable_tabulator.R \name{tabulator} \alias{tabulator} \alias{summary.tabulator} \title{Tabulation of aggregations} \usage{ tabulator( x, rows, columns, datasup_first = NULL, datasup_last = NULL, hidden_data = NULL, row_compose = list(), ... ) \method{summary}{tabulator}(object, ...) } \arguments{ \item{x}{an aggregated data.frame} \item{rows}{column names to use in rows dimensions} \item{columns}{column names to use in columns dimensions} \item{datasup_first}{additional data that will be merged with table and placed after the columns presenting the row dimensions.} \item{datasup_last}{additional data that will be merged with table and placed at the end of the table.} \item{hidden_data}{additional data that will be merged with table, the columns are not presented but can be used with \code{\link[=compose]{compose()}} or \code{\link[=mk_par]{mk_par()}} function.} \item{row_compose}{a list of call to \code{\link[=as_paragraph]{as_paragraph()}} - these calls will be applied to the row dimensions (the name is used to target the displayed column).} \item{...}{named arguments calling function \code{\link[=as_paragraph]{as_paragraph()}}. The names are used as labels and the values are evaluated when the flextable is created.} \item{object}{an object returned by function \code{tabulator()}.} } \value{ an object of class \code{tabulator}. } \description{ It tabulates a data.frame representing an aggregation which is then transformed as a flextable with \link[=as_flextable.tabulator]{as_flextable}. The function allows to define any display with the syntax of flextable in a table whose layout is showing dimensions of the aggregation across rows and columns. \if{html}{\out{ tabulator illustration }} } \section{Methods (by generic)}{ \itemize{ \item \code{summary(tabulator)}: call \code{summary()} to get a data.frame describing mappings between variables and their names in the flextable. This data.frame contains a column named \code{col_keys} where are stored the names that can be used for further selections. }} \note{ This is very first version of the function; be aware it can evolve or change. } \examples{ \dontrun{ set_flextable_defaults(digits = 2, border.color = "gray") library(data.table) # example 1 ---- if (require("stats")) { dat <- aggregate(breaks ~ wool + tension, data = warpbreaks, mean ) cft_1 <- tabulator( x = dat, rows = "wool", columns = "tension", `mean` = as_paragraph(as_chunk(breaks)), `(N)` = as_paragraph(as_chunk(length(breaks), formatter = fmt_int)) ) ft_1 <- as_flextable(cft_1) ft_1 } # example 2 ---- if (require("ggplot2")) { multi_fun <- function(x) { list(mean = mean(x), sd = sd(x)) } dat <- as.data.table(ggplot2::diamonds) dat <- dat[cut \%in\% c("Fair", "Good", "Very Good")] dat <- dat[, unlist(lapply(.SD, multi_fun), recursive = FALSE ), .SDcols = c("z", "y"), by = c("cut", "color") ] tab_2 <- tabulator( x = dat, rows = "color", columns = "cut", `z stats` = as_paragraph(as_chunk(fmt_avg_dev(z.mean, z.sd, digit2 = 2))), `y stats` = as_paragraph(as_chunk(fmt_avg_dev(y.mean, y.sd, digit2 = 2))) ) ft_2 <- as_flextable(tab_2) ft_2 <- autofit(x = ft_2, add_w = .05) ft_2 } # example 3 ---- # data.table version dat <- melt(as.data.table(iris), id.vars = "Species", variable.name = "name", value.name = "value" ) dat <- dat[, list( avg = mean(value, na.rm = TRUE), sd = sd(value, na.rm = TRUE) ), by = c("Species", "name") ] # dplyr version # library(dplyr) # dat <- iris \%>\% # pivot_longer(cols = -c(Species)) \%>\% # group_by(Species, name) \%>\% # summarise(avg = mean(value, na.rm = TRUE), # sd = sd(value, na.rm = TRUE), # .groups = "drop") tab_3 <- tabulator( x = dat, rows = c("Species"), columns = "name", `mean (sd)` = as_paragraph( as_chunk(avg), " (", as_chunk(sd), ")" ) ) ft_3 <- as_flextable(tab_3) ft_3 init_flextable_defaults() } } \seealso{ \code{\link[=as_flextable.tabulator]{as_flextable.tabulator()}}, \code{\link[=summarizor]{summarizor()}}, \code{\link[=as_grouped_data]{as_grouped_data()}}, \code{\link[=tabulator_colnames]{tabulator_colnames()}} } flextable/man/color.Rd0000644000176200001440000000420714411071536014405 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{color} \alias{color} \title{Set font color} \usage{ color(x, i = NULL, j = NULL, color, part = "body", source = j) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{color}{color to use as font color. If a function, function need to return a character vector of colors.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} \item{source}{if color is a function, source is specifying the dataset column to be used as argument to \code{color}. This is only useful if j is colored with values contained in other columns.} } \description{ Change text color of selected rows and columns of a flextable. A function can be used instead of fixed colors. When \code{color} is a function, it is possible to color cells based on values located in other columns, using hidden columns (those not used by argument \code{colkeys}) is a common use case. The argument \code{source} has to be used to define what are the columns to be used for the color definition and the argument \code{j} has to be used to define where to apply the colors and only accept values from \code{colkeys}. } \examples{ ft <- flextable(head(mtcars)) ft <- color(ft, color = "orange", part = "header") ft <- color(ft, color = "red", i = ~ qsec < 18 & vs < 1 ) ft if (require("scales")) { scale <- scales::col_numeric(domain = c(-1, 1), palette = "RdBu") x <- as.data.frame(cor(iris[-5])) x <- cbind( data.frame( colname = colnames(x), stringsAsFactors = FALSE ), x ) ft_2 <- flextable(x) ft_2 <- color(ft_2, j = x$colname, color = scale) ft_2 <- set_formatter_type(ft_2) ft_2 } } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/as_flextable.htest.Rd0000644000176200001440000000231514476430470017053 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.htest} \alias{as_flextable.htest} \title{Transform a 'htest' object into a flextable} \usage{ \method{as_flextable}{htest}(x, ...) } \arguments{ \item{x}{htest object} \item{...}{unused argument} } \description{ produce a flextable describing an object oof class \code{htest}. } \examples{ if (require("stats")) { M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477))) dimnames(M) <- list( gender = c("F", "M"), party = c("Democrat", "Independent", "Republican") ) ft_1 <- as_flextable(chisq.test(M)) ft_1 } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/flextable_html_dependency.Rd0000644000176200001440000000073714476430471020473 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/html_str.R \name{flextable_html_dependency} \alias{flextable_html_dependency} \title{htmlDependency for flextable objects} \usage{ flextable_html_dependency() } \description{ When using loops in an R Markdown for HTML document, the htmlDependency object for flextable must also be added at least once. } \examples{ if (require("htmltools")) { div(flextable_html_dependency()) } } \keyword{internal} flextable/man/set_flextable_defaults.Rd0000644000176200001440000001472014476430471020010 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/defaults.R \name{set_flextable_defaults} \alias{set_flextable_defaults} \alias{init_flextable_defaults} \title{Modify flextable defaults formatting properties} \usage{ set_flextable_defaults( font.family = NULL, font.size = NULL, font.color = NULL, text.align = NULL, padding = NULL, padding.bottom = NULL, padding.top = NULL, padding.left = NULL, padding.right = NULL, border.color = NULL, border.width = NULL, background.color = NULL, line_spacing = NULL, table.layout = NULL, cs.family = NULL, eastasia.family = NULL, hansi.family = NULL, decimal.mark = NULL, big.mark = NULL, digits = NULL, pct_digits = NULL, na_str = NULL, nan_str = NULL, fmt_date = NULL, fmt_datetime = NULL, extra_css = NULL, scroll = NULL, split = NULL, keep_with_next = NULL, tabcolsep = NULL, arraystretch = NULL, float = NULL, fonts_ignore = NULL, theme_fun = NULL, post_process_all = NULL, post_process_pdf = NULL, post_process_docx = NULL, post_process_html = NULL, post_process_pptx = NULL, ... ) init_flextable_defaults() } \arguments{ \item{font.family}{single character value. When format is Word, it specifies the font to be used to format characters in the Unicode range (U+0000-U+007F).} \item{font.size}{font size (in point) - 0 or positive integer value.} \item{font.color}{font color - a single character value specifying a valid color (e.g. "#000000" or "black").} \item{text.align}{text alignment - a single character value, expected value is one of 'left', 'right', 'center', 'justify'.} \item{padding}{padding (shortcut for top, bottom, left and right padding)} \item{padding.bottom, padding.top, padding.left, padding.right}{paragraph paddings - 0 or positive integer value.} \item{border.color}{border color - single character value (e.g. "#000000" or "black").} \item{border.width}{border width in points.} \item{background.color}{cell background color - a single character value specifying a valid color (e.g. "#000000" or "black").} \item{line_spacing}{space between lines of text, 1 is single line spacing, 2 is double line spacing.} \item{table.layout}{'autofit' or 'fixed' algorithm. Default to 'autofit'.} \item{cs.family}{optional and only for Word. Font to be used to format characters in a complex script Unicode range. For example, Arabic text might be displayed using the "Arial Unicode MS" font.} \item{eastasia.family}{optional and only for Word. Font to be used to format characters in an East Asian Unicode range. For example, Japanese text might be displayed using the "MS Mincho" font.} \item{hansi.family}{optional and only for Word. Font to be used to format characters in a Unicode range which does not fall into one of the other categories.} \item{decimal.mark, big.mark, na_str, nan_str}{\link{formatC} arguments used by \code{\link[=colformat_num]{colformat_num()}}, \code{\link[=colformat_double]{colformat_double()}}, and \code{\link[=colformat_int]{colformat_int()}}.} \item{digits}{\link{formatC} argument used by \code{\link[=colformat_double]{colformat_double()}}.} \item{pct_digits}{number of digits for percentages.} \item{fmt_date, fmt_datetime}{formats for date and datetime columns as documented in \code{\link[=strptime]{strptime()}}. Default to '\%Y-\%m-\%d' and '\%Y-\%m-\%d \%H:\%M:\%S'.} \item{extra_css}{css instructions to be integrated with the table.} \item{scroll}{NULL or a list if you want to add a scroll-box. See \strong{scroll} element of argument \code{opts_html} in function \code{\link[=set_table_properties]{set_table_properties()}}.} \item{split}{Word option 'Allow row to break across pages' can be activated when TRUE.} \item{keep_with_next}{default initialization value used by the \code{\link[=paginate]{paginate()}} function corresponding to the Word option "keep rows together" that will be defined in the array.} \item{tabcolsep}{space between the text and the left/right border of its containing cell.} \item{arraystretch}{height of each row relative to its default height, the default value is 1.5.} \item{float}{type of floating placement in the PDF document, one of: \itemize{ \item 'none' (the default value), table is placed after the preceding paragraph. \item 'float', table can float to a place in the text where it fits best \item 'wrap-r', wrap text around the table positioned to the right side of the text \item 'wrap-l', wrap text around the table positioned to the left side of the text \item 'wrap-i', wrap text around the table positioned inside edge-near the binding \item 'wrap-o', wrap text around the table positioned outside edge-far from the binding }} \item{fonts_ignore}{if TRUE, pdf-engine pdflatex can be used instead of xelatex or lualatex. If pdflatex is used, fonts will be ignored because they are not supported by pdflatex, whereas with the xelatex and lualatex engines they are.} \item{theme_fun}{a single character value (the name of the theme function to be applied) or a theme function (input is a flextable, output is a flextable).} \item{post_process_all}{Post-processing function that will allow you to customize the the table. It will be executed before call to post_process_pdf(), post_process_docx(), post_process_html(), post_process_pptx().} \item{post_process_pdf, post_process_docx, post_process_html, post_process_pptx}{Post-processing functions that will allow you to customize the display by output type (pdf, html, docx, pptx). They are executed just before printing the table.} \item{...}{unused or deprecated arguments} } \value{ a list containing previous default values. } \description{ The current formatting properties (see \code{\link[=get_flextable_defaults]{get_flextable_defaults()}}) are automatically applied to every flextable you produce. Use \code{set_flextable_defaults()} to override them. Use \code{init_flextable_defaults()} to re-init all values with the package defaults. } \examples{ ft_1 <- qflextable(head(airquality)) ft_1 old <- set_flextable_defaults( font.color = "#AA8855", border.color = "#8855AA" ) ft_2 <- qflextable(head(airquality)) ft_2 do.call(set_flextable_defaults, old) } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/as_paragraph.Rd0000644000176200001440000000340014375473105015720 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_paragraph} \alias{as_paragraph} \title{Concatenate chunks in a flextable} \usage{ as_paragraph(..., list_values = NULL) } \arguments{ \item{...}{chunk elements that are defining paragraph. If a character is used, it is transformed to a chunk object with function \code{\link[=as_chunk]{as_chunk()}}.} \item{list_values}{a list of chunk elements that are defining paragraph. If specified argument \code{...} is unused.} } \description{ The function is concatenating text and images within paragraphs of a flextable object, this function is to be used with functions such as \code{\link[=compose]{compose()}}, \code{\link[=add_header_lines]{add_header_lines()}}, \code{\link[=add_footer_lines]{add_footer_lines()}}. This allows the concatenation of formatted pieces of text (chunks) that represent the content of a paragraph. The cells of a flextable contain each a single paragraph. This paragraph is made of chunks that can be text, images or plots, equations and links. } \examples{ library(flextable) ft <- flextable(airquality[sample.int(150, size = 10), ]) ft <- compose(ft, j = "Wind", value = as_paragraph( as_chunk(Wind, props = fp_text_default(color = "orange")), " ", minibar(value = Wind, max = max(airquality$Wind), barcol = "orange", bg = "black", height = .15) ), part = "body" ) ft <- autofit(ft) ft } \seealso{ \code{\link[=as_chunk]{as_chunk()}}, \code{\link[=minibar]{minibar()}}, \code{\link[=as_image]{as_image()}}, \code{\link[=hyperlink_text]{hyperlink_text()}} Other functions for mixed content paragraphs: \code{\link{append_chunks}()}, \code{\link{compose}()}, \code{\link{prepend_chunks}()} } \concept{functions for mixed content paragraphs} flextable/man/colformat_image.Rd0000644000176200001440000000247314402205763016423 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_image} \alias{colformat_image} \title{Format cells as images} \usage{ colformat_image( x, i = NULL, j = NULL, width, height, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{width, height}{size of the png file in inches} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format image paths as images in a flextable. } \examples{ img.file <- file.path(R.home("doc"), "html", "logo.jpg") dat <- head(iris) dat$Species <- as.character(dat$Species) dat[c(1, 3, 5), "Species"] <- img.file myft <- flextable(dat) myft <- colformat_image( myft, i = c(1, 3, 5), j = "Species", width = .20, height = .15 ) ft <- autofit(myft) ft } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/keep_with_next.Rd0000644000176200001440000000275014476430471016315 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{keep_with_next} \alias{keep_with_next} \title{Set Word 'Keep with next' instructions} \usage{ keep_with_next(x, i = NULL, value = TRUE, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{value}{TRUE or FALSE. When applied to a group, all rows except the last one should be flagged with attribute 'Keep with next'.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The 'Keep with next' functionality in 'Word', applied to the rows of a table, ensures that the rows with that attribute stays together and does not break across multiple pages. This function allows much better control of breaks between pages than the global \code{keep_with_next} parameter. } \examples{ library(flextable) dat <- iris[c(1:25, 51:75, 101:125), ] ft <- qflextable(dat) ft <- keep_with_next( x = ft, i = c(1:24, 26:49, 51:74), value = TRUE ) save_as_docx(ft, path = tempfile(fileext = ".docx")) } \seealso{ \code{\link[=paginate]{paginate()}} Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/figures/0000755000176200001440000000000014417541353014446 5ustar liggesusersflextable/man/figures/fig_formats.png0000644000176200001440000000615414211217544017454 0ustar liggesusers‰PNG  IHDRdŸ–EgAMA± üasRGB®ÎérPLTEGpL|3(&OŽÐD$ÉG&ÖcD¿J*1*Î( 2&J„åzZöõõÿÿÿ*V™äM&Ä>ÓR0ÿkñe)ÿ!íëêíkF—=%Úá뫺Ñ:c ûngq+ñ¬¢000ñÏÊ|–¾e…µoooýC9ñÔ ‚tRNS4ç¿Uþý!þ€WÅŸµƒé•æ ~IDATxÚí‹zª:FaƒPÚ[Í1ˆÚ-ïÿŠ'„‹Ü3“±{;Z…¢íg–&3¹9ÎÓžö´§=ퟱaÏÒšÛ"o2/Ò†ò"L¼ÙOoÎëKmå‰+^"^7ù8Ïï±qø{ óæò&^ò6ðõýýÏGaM$ÚkÙg8 z¶$t_k…¹óVÿ®ëû®ð )#`c)Ïò7…syq_lq²hØ\ qýÈ[ŹQiëµeŠ’ÍR‚4Fs¸š@jNYA½:¡Ó¤cH8ŒbF þº`ÑRPñ1ÿN¸óŒ¼ñ\#®5 ŽE “(檲üuÜ2Ú²µþC¢X9!÷#2 ä­¸  D: ‹Yâ¯âx ˆ°ÜÂʹ#÷üLˆ«–Ål@¢Ž @$Â¥ŸÉ=‰H¿†¯Ã@ÞÅé›s"Ä"n¡i 5+Ç Jýyh)[YáˆBDó+ly)_?ŽãCÇþ(íø¹ÂuƒÐu8+"­fï€BòöÖü@ öª/Q j‘˜Ùà‰Liþji ŸfD@èzN ¥F|LC¨Ì$Õ¥þAyKfê9&*/R/Æ¡ÔI±Dl§)´€$•Ôžß]ÅZ@&‰ÁkäoâÆ±&)Gbda,dšÇ4 "€,Kd) “õ•Èx­¥ÂR"¢laû†öP@BêaY¦Î§+ïÓȼ‡â­&M „êáL ž=üE@®—±Û$Z)L d­ ä,*¬ó^Ùa’©½È#·ÓÐmßü° ¿»ö}µÛD”@F;ˆÒœ÷{U232-$ ¶} êÇ qßn‡C2ìØ@è? $Ú¢¬$²Ö’Yâ+Jü¿Q“—­¶².ÇQë ·h ÁJKíÔ‹½•*ë‘€ ZY>Èö „j9çZ@\3 îoWÈP¢:ÙçmÚÔÐ HøK€‡/0ðP©g©(lbˆ£ ¤¸ìü… ˆ¥`ÈÎD!;g!§Ž‚PÕ’§E¨ ž‰B<} §ã±ìrÒiö¶€ìš˜+¤ßÐd{3€ y §Ó©ª’’„RÉA–ðÑU÷ËÊWf>¤‹À€0Û@Ø€ TääØ(õkñökãÊæb ȦPP´BwF é¹uP•JÒÕSv€$MMT ’&’ب]&€+Ia“?nj*+Ò«³Ô@DQ[ª²ð@R© ÒÔD¥Ö¸bÖÊê(dS<­L²ÆÇ!ûŒÛie5BuŽâ«€œªr¬Tz95ŽÍ€” a¼0Vâa>¤×ÎRGêù 2º ŽòAꊩò¤áP.¶"Ф>-}ëÙ@!Ýœ¯ˆlc1eŸ!ˆÛ’?哈«’Ôå~­Þ½9”«5…lø­̤FRÒu"* ¥Kçª9$ Ü …)„*3' ·fVÜxŽº 0PNíCn@¶EŽ™(dr.‹46rËìð@Ô£N.µ«¨¿ÿÇú,Ñîi+„´"%#$b¢áÒË äLÍÜr'q !†ŸS™“[3+÷&·V0A„…Ê8dÓô!u¤h¢ŠÂëË,£œž³|¶gÓT ˆ§ä¿©¸°©“² e™ÖxN˜°¯ÒU¶•Õ §°2m’òs–7y>Y—åé_jdUÕSP…@€$¥ó–u׉•g×’'YFìªð!Òñ!}§~˜Ïg„òó>;ó”¤Ù¹òì´+"|ÎäXJá(+«êìÒ ZYm…ð"6¤&>¤Óî’Ëbó²ðÙyOYŠjÕW@ È¥t‰|ª]Ç!Ÿ®‡Ü¬ŠrÙ°ÀH!>H.ÎZ£æögñ ÷:uuÄ\‹¢?Ò(Ïá‰-…&o¤LluâÂàk. r¹†´×Åž‹¦ÿ&¿ä âC[Y9] çQ¥RH?,4TH#±Øitƒ¾¾‚ Ø „gy‹Š¾æ\¯•ÕÏ$Ô&YÌ'YsU ­ëiȧ*ä–Yà14ËÒ3…Äí'³’´¶~¨HÕ™“é.®ÇÒg^ý:žNcw”BHÚï¡Â8uvÎxÝäµ$œ Õµ2'- RVÆ…?¢ÂBHÒ¬+Vƒ}궤2¹{†t¥ã€8“É,­ÌI» wS…è—Êdz#*,T÷n*)3…(ãT¦v9nj H;ÙÅUº—Õ#@¦3'íA¤áÊ¢%C.ÄV¤nH J©ö¹HH;¹A× `@’VGHí¹bZ4»·B<ÊK¨E´`@r'SU Po©òîIëlÀ…XŠÔGÆe¡€D* ùèjŽ^Ô ä„ \Z.­n둺%…(¤YžH<#5ƒ‰P@cN:@®ÍžÂ[Çáé® AQwá2N9z94ÏUܽÕXácNº#I‹iz”GUÈ óÔá@|ÐÈE sÒ’´œx2æBôÇeY÷!Þ/Âñ@Ž-ÇÍ…Ü?ñâ‚€pø˜“.ÓI|Ç/×¶¿Ú2‡ -3X|Åée¬D%tú°©bW!ž³(dÖ‘ÊÒ]/Ko~H05 AˇøËi$³b ÏéTÖ#NúD œ…L ª0Dæä—‰–ÒÏ !ˆÌÉ/…ËD]š&2:LòÃ2NLÊjÖþ¸“&sòˆ“>á@ÀÓ¢“oi? !?ÅQÇß߉M 4n‰9&sò€“>á ŸŸ¼ø%y”‘ǘ6þ¸“DÔZü\¡œafëÜc­“/(ðÒ,‘ŽùãÏ÷ô#e!|Èè$ª”Ç”§ØéS¸øÌˆç`’+B¢„ ~q±¤=î$™Ìö‚2'‹-Ï4Áãâ)žla‹¹^Fmx³¶E_“vÁ,`Ö­²¤û@ò^N FgP2' ­¹øfÄC,ñÇj§Î* —ÒÁKO¯ ¤1‰*N§Â@™“¥ÁÅþÝÿù.x@€x¨E0“[û¶$odi-@³¢|>°ðÌ’Ëľz·ò~q±@~D¬ºï.Ü÷©ñt>ÁHí…ª§t<¾ëÌc®øHA“EäcÿU¸GÏ–˜ÕÙ¥m¤öê ÅXCb麖ЙÓB×õ}×Õü'Q¾çM¾õïK©á>† 7oOÓuؼ@ M1µÈ¸þÝyÑ6§lw¼¼ùŸ¦8>}çiVEâ™àð¢g Φe {–ÝÓžö´ßnÿ§ê÷f‘ÄIEND®B`‚flextable/man/figures/logo.png0000644000176200001440000000314614006002754016107 0ustar liggesusers‰PNG  IHDR|ýFÿugAMA± üasRGB®ÎéHPLTEïïïl’ªRhJ‘´m¹ËÕGpL”·ÉÔÞäf˜+¨f™ëssh¢¿f™ì||f˜ë[[f™f™G_wëUU?ï²tRNS€Ñ²ïÃê“¡œˆ¸Ø|Ö²%ÌRô˜(}m›IDATxÚí\‰râ:쀤€ÀîÿÿéÓeãC²%Ùy„®­Øe š¹Ú“ìŒñç‰À’9¿>‰üÊïŸ×'Ÿ?ïŸço&?ßî¿•üÈ=+SþXzTû~W|ïQl.á ýí¼=ù1ÄY£±ðmŽ“7g„DeèQãqì>êBòòâèŽÛ&äM°ûÇ8ô×Õɻ啂lB^•|P^Â;ž´¦E¡Ï"ïÛúWºWm±·`%Š‹- f “[܃af”j‚͜ƘoÀF–ùeZÀ­Å>"’ü¹Š‹œò⬛g¾¨Ï7¢•—©¸Èñ8uòŒœûM`…´yÀx¼ì²ÙZJ.Ï´!V^Ôd²êçC-5¦3®=¡²?%c2­9­â É£ZJÜ1Z£Am&L`NqQ¢¥.ϬÑdÝù˜âÆ}ìòjò ÂþÈÂTÙ!¥¥w=ð Ò!ÏÌW@(­¸ÈjULêªÆåJ¡IÅÅL°C:›pj²/r§Ë±òê›q2÷Mãnë=eóL*І>AÞ–W?Ÿ²9Æã¥ù¨CLq×Òö#wWW s9¥=Fq¿Zbª¼ˆi;Áî·Ä:¼ £UÉßy¯U1jZbk³¡_™ùQvž\¶·mŠxÛ»ê’Ø¬GΘ‘AK¬L¡Û“Kë{ê·ÄbêÊ!¿K9h‰ýÂÁtè£}e„"rw¯L¶Ä_ÿpø×Çax¡ÁW¹à.Þ‰–8EN+‘3ïDK¼±åÎhæÝ?N³-oZÓxK¼¹åþþo‰“ä´¹½ âzv99àpêƒèÇ¥˜\Þá›0"×É&éâƒ;œႱ¼ÿÊåоµ”<ÞãVìlbC;ÿy¹¡?/úøõÁÉᆔªÔIEND®B`‚flextable/man/empty_blanks.Rd0000644000176200001440000000333114411071536015754 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{empty_blanks} \alias{empty_blanks} \title{Make blank columns as transparent} \usage{ empty_blanks(x, width = 0.05, unit = "in", part = "all") } \arguments{ \item{x}{a flextable object} \item{width}{width of blank columns (.1 inch by default).} \item{unit}{unit for width, one of "in", "cm", "mm".} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ blank columns are set as transparent. This is a shortcut function that will delete top and bottom borders, change background color to transparent, display empty content and set blank columns' width. } \examples{ typology <- data.frame( col_keys = c( "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species" ), what = c("Sepal", "Sepal", "Petal", "Petal", " "), measure = c("Length", "Width", "Length", "Width", "Species"), stringsAsFactors = FALSE ) typology ftab <- flextable(head(iris), col_keys = c( "Species", "break1", "Sepal.Length", "Sepal.Width", "break2", "Petal.Length", "Petal.Width" )) ftab <- set_header_df(ftab, mapping = typology, key = "col_keys") ftab <- merge_h(ftab, part = "header") ftab <- theme_vanilla(ftab) ftab <- empty_blanks(ftab) ftab <- width(ftab, j = c(2, 5), width = .1) ftab } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/merge_none.Rd0000644000176200001440000000201214476430471015405 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/merge_flextable.R \name{merge_none} \alias{merge_none} \title{Delete flextable merging informations} \usage{ merge_none(x, part = "all") } \arguments{ \item{x}{\code{flextable} object} \item{part}{partname of the table where merge has to be done.} } \description{ Delete all merging informations from a flextable. } \examples{ typology <- data.frame( col_keys = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species"), what = c("Sepal", "Sepal", "Petal", "Petal", "Species"), measure = c("Length", "Width", "Length", "Width", "Species"), stringsAsFactors = FALSE ) ft <- flextable(head(iris)) ft <- set_header_df(ft, mapping = typology, key = "col_keys") ft <- merge_v(ft, j = c("Species")) ft <- theme_tron_legacy(merge_none(ft)) ft } \seealso{ Other flextable merging function: \code{\link{merge_at}()}, \code{\link{merge_h_range}()}, \code{\link{merge_h}()}, \code{\link{merge_v}()} } \concept{flextable merging function} flextable/man/plot.flextableGrob.Rd0000644000176200001440000000055614310450150017016 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/grid_grobs.R \name{plot.flextableGrob} \alias{plot.flextableGrob} \title{plot a flextable grob} \usage{ \method{plot}{flextableGrob}(x, ...) } \arguments{ \item{x}{a flextableGrob object} \item{...}{additional arguments passed to other functions} } \description{ plot a flextable grob } flextable/man/as_flextable.Rd0000644000176200001440000000216114410655214015715 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable} \alias{as_flextable} \title{Method to transform objects into flextables} \usage{ as_flextable(x, ...) } \arguments{ \item{x}{object to be transformed as flextable} \item{...}{arguments for custom methods} } \description{ This is a convenient function to let users create flextable bindings from any objects. Users should consult documentation of corresponding method to understand the details and see what arguments can be used. } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()} } \concept{as_flextable methods} flextable/man/append_chunks.Rd0000644000176200001440000000250714375473105016121 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/append_chunk.R \name{append_chunks} \alias{append_chunks} \title{Append chunks to flextable content} \usage{ append_chunks(x, ..., i = NULL, j = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{...}{chunks to be appened, see \code{\link[=as_chunk]{as_chunk()}}, \code{\link[=gg_chunk]{gg_chunk()}} and other chunk elements for paragraph.} \item{i}{rows selection} \item{j}{column selection} \item{part}{partname of the table (one of 'body', 'header', 'footer')} } \description{ append chunks (for example chunk \code{\link[=as_chunk]{as_chunk()}}) in a flextable. } \examples{ library(flextable) img.file <- file.path(R.home("doc"), "html", "logo.jpg") ft_1 <- flextable(head(cars)) ft_1 <- append_chunks(ft_1, # where to append i = c(1, 3, 5), j = 1, # what to append as_chunk(" "), as_image(src = img.file, width = .20, height = .15) ) ft_1 <- set_table_properties(ft_1, layout = "autofit") ft_1 } \seealso{ \code{\link[=as_chunk]{as_chunk()}}, \code{\link[=as_sup]{as_sup()}}, \code{\link[=as_sub]{as_sub()}}, \code{\link[=colorize]{colorize()}} Other functions for mixed content paragraphs: \code{\link{as_paragraph}()}, \code{\link{compose}()}, \code{\link{prepend_chunks}()} } \concept{functions for mixed content paragraphs} flextable/man/as_flextable.kmeans.Rd0000644000176200001440000000237014476430470017203 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.kmeans} \alias{as_flextable.kmeans} \title{Transform a 'kmeans' object into a flextable} \usage{ \method{as_flextable}{kmeans}(x, digits = 4, ...) } \arguments{ \item{x}{a \code{\link[=kmeans]{kmeans()}} object} \item{digits}{number of digits for the numeric columns} \item{...}{unused argument} } \description{ produce a flextable describing a kmeans object. The function is only using package 'broom' that provides the data presented in the resulting flextable. } \examples{ if (require("stats")) { cl <- kmeans(scale(mtcars[1:7]), 5) ft <- as_flextable(cl) ft } } \seealso{ Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.grouped_data}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/as_equation.Rd0000644000176200001440000000406114476430470015604 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_equation} \alias{as_equation} \title{Equation chunk} \usage{ as_equation(x, width = 1, height = 0.2, unit = "in", props = NULL) } \arguments{ \item{x}{values containing the 'MathJax' equations} \item{width, height}{size of the resulting equation} \item{unit}{unit for width and height, one of "in", "cm", "mm".} \item{props}{an \code{\link[=fp_text_default]{fp_text_default()}} or \code{\link[officer:fp_text]{officer::fp_text()}} object to be used to format the text. If not specified, it will be the default value corresponding to the cell.} } \description{ This function is used to insert equations into flextable. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. To use this function, package 'equatags' is required; also \code{equatags::mathjax_install()} must be executed only once to install necessary dependencies. } \examples{ library(flextable) if (require("equatags") && mathjax_available()) { eqs <- c( "(ax^2 + bx + c = 0)", "a \\\\ne 0", "x = {-b \\\\pm \\\\sqrt{b^2-4ac} \\\\over 2a}" ) df <- data.frame(formula = eqs) df ft <- flextable(df) ft <- compose( x = ft, j = "formula", value = as_paragraph(as_equation(formula, width = 2, height = .5)) ) ft <- align(ft, align = "center", part = "all") ft <- width(ft, width = 2) ft } } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/dim_pretty.Rd0000644000176200001440000000255214255321756015460 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable_sizes.R \name{dim_pretty} \alias{dim_pretty} \title{Calculate pretty dimensions} \usage{ dim_pretty(x, part = "all", unit = "in", hspans = "none") } \arguments{ \item{x}{flextable object} \item{part}{partname of the table (one of 'all', 'body', 'header' or 'footer')} \item{unit}{unit for returned values, one of "in", "cm", "mm".} \item{hspans}{specifies how cells that are horizontally are included in the calculation. It must be one of the following values "none", "divided" or "included". If "none", widths of horizontally spanned cells is set to 0 (then do not affect the widths); if "divided", widths of horizontally spanned cells is divided by the number of spanned cells; if "included", all widths (included horizontally spanned cells) will be used in the calculation.} } \description{ return minimum estimated widths and heights for each table columns and rows in inches. } \examples{ ftab <- flextable(head(mtcars)) dim_pretty(ftab) } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{set_table_properties}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/theme_vanilla.Rd0000644000176200001440000000433214364612403016077 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_vanilla} \alias{theme_vanilla} \title{Apply vanilla theme} \usage{ theme_vanilla(x) } \arguments{ \item{x}{a flextable object} } \description{ Apply theme vanilla to a flextable: The external horizontal lines of the different parts of the table (body, header, footer) are black 2 points thick, the external horizontal lines of the different parts are black 0.5 point thick. Header text is bold, text columns are left aligned, other columns are right aligned. } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_vanilla(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/vline.Rd0000644000176200001440000000230614476430471014412 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{vline} \alias{vline} \title{Set vertical borders} \usage{ vline(x, i = NULL, j = NULL, border = NULL, part = "all") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{border}{border properties defined by a call to \code{\link[=fp_border]{fp_border()}}} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function is applying vertical borders to inner content of one or all parts of a flextable. The lines are the right borders of selected cells. } \examples{ library(officer) std_border <- fp_border(color = "orange") ft <- flextable(head(iris)) ft <- border_remove(x = ft) # add vertical borders ft <- vline(ft, border = std_border) ft } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()} } \concept{borders management} flextable/man/body_add_flextable.Rd0000644000176200001440000000247114440663650017071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/body_add_flextable.R \name{body_add_flextable} \alias{body_add_flextable} \title{Add flextable into a Word document} \usage{ body_add_flextable( x, value, align = NULL, pos = "after", split = NULL, topcaption = TRUE, keepnext = NULL ) } \arguments{ \item{x}{an rdocx object} \item{value}{\code{flextable} object} \item{align}{left, center (default) or right.} \item{pos}{where to add the flextable relative to the cursor, one of "after", "before", "on" (end of line).} \item{split}{set to TRUE if you want to activate Word option 'Allow row to break across pages'.} \item{topcaption}{if TRUE caption is added before the table, if FALSE, caption is added after the table.} \item{keepnext}{Defunct in favor of \code{\link[=paginate]{paginate()}}.} } \description{ add a flextable into a Word document. } \examples{ library(officer) # autonum for caption autonum <- run_autonum(seq_id = "tab", bkm = "mtcars") ftab <- flextable(head(mtcars)) ftab <- set_caption(ftab, caption = "mtcars data", autonum = autonum) ftab <- autofit(ftab) doc <- read_docx() doc <- body_add_flextable(doc, value = ftab) fileout <- tempfile(fileext = ".docx") # fileout <- "test.docx" # uncomment to write in your working directory print(doc, target = fileout) } flextable/man/delete_rows.Rd0000644000176200001440000000235114515157112015601 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{delete_rows} \alias{delete_rows} \title{Delete flextable rows} \usage{ delete_rows(x, i = NULL, part = "body") } \arguments{ \item{x}{a \code{flextable} object} \item{i}{rows selection} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function removes one or more rows from a 'flextable'. } \details{ Deleting one or more rows will result in the deletion of any span parameters that may have been set previously. They will have to be redone after this operation or performed only after this deletion. } \examples{ ft <- flextable(head(iris)) ft <- delete_rows(ft, i = 1:5, part = "body") ft } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/border_remove.Rd0000644000176200001440000000151114476430470016123 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{border_remove} \alias{border_remove} \title{Remove borders} \usage{ border_remove(x) } \arguments{ \item{x}{a flextable object} } \description{ The function is deleting all borders of the flextable object. } \examples{ dat <- iris[c(1:5, 51:55, 101:105), ] ft_1 <- flextable(dat) ft_1 <- theme_box(ft_1) ft_1 # remove all borders ft_2 <- border_remove(x = ft_1) ft_2 } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{surround}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/align.Rd0000644000176200001440000000311514411071536014356 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{align} \alias{align} \alias{align_text_col} \alias{align_nottext_col} \title{Set text alignment} \usage{ align( x, i = NULL, j = NULL, align = c("left", "center", "right", "justify"), part = "body" ) align_text_col(x, align = "left", header = TRUE, footer = TRUE) align_nottext_col(x, align = "right", header = TRUE, footer = TRUE) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{align}{text alignment - a single character value, expected value is one of 'left', 'right', 'center', 'justify'.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} \item{header}{should the header be aligned with the body} \item{footer}{should the footer be aligned with the body} } \description{ change text alignment of selected rows and columns of a flextable. } \examples{ ft <- flextable(head(mtcars)[, 3:6]) ft <- align(ft, align = "right", part = "all") ft <- theme_tron_legacy(ft) ft ftab <- flextable(mtcars) ftab <- align_text_col(ftab, align = "left") ftab <- align_nottext_col(ftab, align = "right") ftab } \seealso{ Other sugar functions for table style: \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/colformat_double.Rd0000644000176200001440000000244714402205763016614 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_double} \alias{colformat_double} \title{Format numeric cells} \usage{ colformat_double( x, i = NULL, j = NULL, big.mark = get_flextable_defaults()$big.mark, decimal.mark = get_flextable_defaults()$decimal.mark, digits = get_flextable_defaults()$digits, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{big.mark, digits, decimal.mark}{see \code{\link[=formatC]{formatC()}}} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format numeric cells in a flextable. } \examples{ dat <- mtcars ft <- flextable(head(dat)) ft <- colformat_double( x = ft, big.mark = ",", digits = 2, na_str = "N/A" ) autofit(ft) } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/footnote.Rd0000644000176200001440000000457514507616476015152 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/footnote.R \name{footnote} \alias{footnote} \title{Add footnotes to flextable} \usage{ footnote( x, i = NULL, j = NULL, value, ref_symbols = NULL, part = "body", inline = FALSE, sep = "; " ) } \arguments{ \item{x}{a flextable object} \item{i, j}{cellwise rows and columns selection} \item{value}{a call to function \code{\link[=as_paragraph]{as_paragraph()}}.} \item{ref_symbols}{character value, symbols to append that will be used as references to notes.} \item{part}{partname of the table (one of 'body', 'header', 'footer')} \item{inline}{whether to add footnote on same line as previous footnote or not} \item{sep}{used only when inline = TRUE, character string to use as a separator between footnotes.} } \description{ The function let add footnotes to a flextable object by adding some symbols in the flextable and associated notes in the footer of the flextable. Symbols are added to the cells designated by the selection \code{i} and \code{j}. If you use i = c(1,3) and j = c(2,5), then you will add the symbols (or the repeated symbol) to cells \verb{[1,2]} and \verb{[3,5]}. \if{html}{\out{ add_footer illustration See https://www.ardata.fr/en/flextable-gallery/2022-06-23-separate-headers/ for the example shown }} } \examples{ ft_1 <- flextable(head(iris)) ft_1 <- footnote(ft_1, i = 1, j = 1:3, value = as_paragraph( c( "This is footnote one", "This is footnote two", "This is footnote three" ) ), ref_symbols = c("a", "b", "c"), part = "header" ) ft_1 <- valign(ft_1, valign = "bottom", part = "header") ft_1 <- autofit(ft_1) ft_2 <- flextable(head(iris)) ft_2 <- autofit(ft_2) ft_2 <- footnote(ft_2, i = 1, j = 1:2, value = as_paragraph( c( "This is footnote one", "This is footnote two" ) ), ref_symbols = c("a", "b"), part = "header", inline = TRUE ) ft_2 <- footnote(ft_2, i = 1, j = 3:4, value = as_paragraph( c( "This is footnote three", "This is footnote four" ) ), ref_symbols = c("c", "d"), part = "header", inline = TRUE ) ft_2 ft_3 <- flextable(head(iris)) ft_3 <- autofit(ft_3) ft_3 <- footnote( x = ft_3, i = 1:3, j = 1:3, ref_symbols = "a", value = as_paragraph("This is footnote one") ) ft_3 } flextable/man/rotate.Rd0000644000176200001440000000635114411071536014567 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{rotate} \alias{rotate} \title{Rotate cell text} \usage{ rotate(x, i = NULL, j = NULL, rotation, align = NULL, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{rotation}{one of "lrtb", "tbrl", "btlr".} \item{align}{vertical alignment of paragraph within cell, one of "center" or "top" or "bottom".} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ It can be useful to be able to change the direction, when the table headers are huge for example, header labels can be rendered as "tbrl" (top to bottom and right to left) corresponding to a 90 degrees rotation or "btlr" corresponding to a 270 degrees rotation. The function change cell text direction. By default, it is "lrtb" which mean from left to right and top to bottom. 'Word' and 'PowerPoint' don't handle auto height with rotated headers. So you need to set header heights (with function \code{\link[=height]{height()}}) and set rule "exact" for rows heights (with function \code{\link[=hrule]{hrule()}}) otherwise Word and PowerPoint outputs will have small height not corresponding to the necessary height to display the text. flextable doesn't do the rotation by any angle. It only rotates by a number of right angles. This choice is made to ensure the same rendering between Word, PowerPoint (limited to angles 0, 270 and 90) HTML and PDF. } \details{ When function \code{autofit} is used, the rotation will be ignored. In that case, use \link{dim_pretty} and \link{width} instead of \link{autofit}. } \examples{ library(flextable) ft_1 <- flextable(head(iris)) ft_1 <- rotate(ft_1, j = 1:4, align = "bottom", rotation = "tbrl", part = "header") ft_1 <- rotate(ft_1, j = 5, align = "bottom", rotation = "btlr", part = "header") # if output is docx or pptx, think about (1) set header heights # and (2) set rule "exact" for rows heights because Word # and PowerPoint don't handle auto height with rotated headers ft_1 <- height(ft_1, height = 1.2, part = "header") ft_1 <- hrule(ft_1, i = 1, rule = "exact", part = "header") ft_1 dat <- data.frame( a = c("left-top", "left-middle", "left-bottom"), b = c("center-top", "center-middle", "center-bottom"), c = c("right-top", "right-middle", "right-bottom") ) ft_2 <- flextable(dat) ft_2 <- theme_box(ft_2) ft_2 <- height_all(x = ft_2, height = 1.3, part = "body") ft_2 <- hrule(ft_2, rule = "exact") ft_2 <- rotate(ft_2, rotation = "tbrl") ft_2 <- width(ft_2, width = 1.3) ft_2 <- align(ft_2, j = 1, align = "left") ft_2 <- align(ft_2, j = 2, align = "center") ft_2 <- align(ft_2, j = 3, align = "right") ft_2 <- valign(ft_2, i = 1, valign = "top") ft_2 <- valign(ft_2, i = 2, valign = "center") ft_2 <- valign(ft_2, i = 3, valign = "bottom") ft_2 } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/add_body.Rd0000644000176200001440000000422414515157112015033 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_body} \alias{add_body} \title{Add column values as new lines in body} \usage{ add_body(x, top = TRUE, ..., values = NULL) } \arguments{ \item{x}{a flextable object} \item{top}{should the rows be inserted at the top or the bottom.} \item{...}{named arguments (names are data colnames) of values to add. It is important to insert data of the same type as the original data, otherwise it will be transformed (probably into strings if you add a \code{character} where a \code{double} is expected). This makes possible to still format cell contents with the \verb{colformat_*} functions, for example \code{\link[=colformat_num]{colformat_num()}}.} \item{values}{a list of name-value pairs of labels or values, names should be existing col_key values. This argument can be used instead of \code{...} for programming purpose (If \code{values} is supplied argument \code{...} is ignored).} } \description{ The function adds a list of values to be inserted as new rows in the body. The values are inserted in existing columns of the input data of the flextable. Rows can be inserted at the top or the bottom of the body. If some columns are not provided, they will be replaced by \code{NA} and displayed as empty. } \examples{ ft <- flextable(head(iris), col_keys = c( "Species", "Sepal.Length", "Petal.Length", "Sepal.Width", "Petal.Width" ) ) ft <- add_body( x = ft, Sepal.Length = 1:5, Sepal.Width = 1:5 * 2, Petal.Length = 1:5 * 3, Petal.Width = 1:5 + 10, Species = "Blah", top = FALSE ) ft <- theme_booktabs(ft) ft } \seealso{ \code{\link[=flextable]{flextable()}} Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/lollipop.Rd0000644000176200001440000000507714476430471015137 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{lollipop} \alias{lollipop} \title{Mini lollipop chart chunk wrapper} \usage{ lollipop( value, min = NULL, max = NULL, rangecol = "#CCCCCC", bg = "transparent", width = 1, height = 0.2, unit = "in", raster_width = 30, positivecol = "#00CC00", negativecol = "#CC0000", neutralcol = "#CCCCCC", neutralrange = c(0, 0), rectanglesize = 2 ) } \arguments{ \item{value}{values containing the bar size} \item{min}{min bar size. Default min of value} \item{max}{max bar size. Default max of value} \item{rangecol}{bar color} \item{bg}{background color} \item{width, height}{size of the resulting png file in inches} \item{unit}{unit for width and height, one of "in", "cm", "mm".} \item{raster_width}{number of pixels used as width} \item{positivecol}{box color of positive values} \item{negativecol}{box color of negative values} \item{neutralcol}{box color of neutral values} \item{neutralrange}{minimal and maximal range of neutral values (default: 0)} \item{rectanglesize}{size of the rectangle (default: 2, max: 5) when interpolating value.} } \description{ This function is used to insert lollipop charts into flextable with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}}. } } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ iris$Sepal.Ratio <- (iris$Sepal.Length - mean(iris$Sepal.Length)) / mean(iris$Sepal.Length) ft <- flextable(tail(iris, n = 10)) ft <- compose(ft, j = "Sepal.Ratio", value = as_paragraph( lollipop(value = Sepal.Ratio, min = -.25, max = .25) ), part = "body" ) ft <- autofit(ft) ft } \seealso{ \code{\link[=compose]{compose()}}, \code{\link[=as_paragraph]{as_paragraph()}} Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/set_formatter.Rd0000644000176200001440000000477414402205763016157 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{set_formatter} \alias{set_formatter} \alias{set_formatter_type} \title{Set column formatter functions} \usage{ set_formatter(x, ..., values = NULL, part = "body") set_formatter_type( x, fmt_double = "\%.03f", fmt_integer = "\%.0f", fmt_date = "\%Y-\%m-\%d", fmt_datetime = "\%Y-\%m-\%d \%H:\%M:\%S", true = "true", false = "false", na_str = "" ) } \arguments{ \item{x}{a flextable object} \item{...}{Name-value pairs of functions, names should be existing col_key values} \item{values}{format functions, If values is supplied argument \code{...} is ignored. \itemize{ \item It can be a list of name-value pairs of functions, names should be existing col_key values. \item If \code{values} is a single function, it will be applied to each column. }} \item{part}{part of the table (one of 'body' or 'header' or 'footer') where to apply the formatter functions.} \item{fmt_double, fmt_integer}{arguments used by \code{sprintf} to format double and integer columns.} \item{fmt_date, fmt_datetime}{arguments used by \code{format} to format date and date time columns.} \item{false, true}{string to be used for logical columns} \item{na_str}{string for NA values} } \description{ Apply formatter functions to column keys. Functions should have a single argument (the vector) and should return the formatted values as a character vector. } \section{set_formatter_type}{ \code{set_formatter_type} is an helper function to quickly define formatter functions regarding to column types. This function will be deprecated in favor of the \verb{colformat_*} functions, for example \code{\link[=colformat_double]{colformat_double()}}. } \examples{ ft <- flextable(head(iris)) ft <- set_formatter( x = ft, Sepal.Length = function(x) sprintf("\%.02f", x), Sepal.Width = function(x) sprintf("\%.04f", x) ) ft <- theme_vanilla(ft) ft } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()} Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_datetime}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()} } \concept{cells formatters} flextable/man/save_as_image.Rd0000644000176200001440000000251114515045006016044 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{save_as_image} \alias{save_as_image} \title{Save a flextable in a 'png' or 'svg' file} \usage{ save_as_image(x, path, expand = 10, res = 200, ...) } \arguments{ \item{x}{a flextable object} \item{path}{image file to be created. It should end with '.png' or '.svg'.} \item{expand}{space in pixels to add around the table.} \item{res}{The resolution of the device} \item{...}{unused arguments} } \value{ a string containing the full name of the generated file } \description{ Save a flextable as a png or svg image. } \examples{ library(gdtools) register_liberationsans() set_flextable_defaults(font.family = "Liberation Sans") ft <- flextable(head(mtcars)) ft <- autofit(ft) tf <- tempfile(fileext = ".png") save_as_image(x = ft, path = tf) init_flextable_defaults() } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/rtf_add.flextable.Rd0000644000176200001440000000124014371453413016634 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rtf_str.R \name{rtf_add.flextable} \alias{rtf_add.flextable} \title{Add a 'flextable' into an RTF document} \usage{ \method{rtf_add}{flextable}(x, value, ...) } \arguments{ \item{x}{rtf object, created by \code{\link[=rtf_doc]{rtf_doc()}}.} \item{value}{a flextable object} \item{...}{unused arguments} } \description{ \code{\link[=rtf_add]{rtf_add()}} method for adding flextable objects into 'RTF' documents. } \examples{ library(flextable) library(officer) ft <- flextable(head(iris)) ft <- autofit(ft) z <- rtf_doc() z <- rtf_add(z, ft) print(z, target = tempfile(fileext = ".rtf")) } flextable/man/colformat_datetime.Rd0000644000176200001440000000233014402205763017125 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/formatters.R \name{colformat_datetime} \alias{colformat_datetime} \title{Format datetime cells} \usage{ colformat_datetime( x, i = NULL, j = NULL, fmt_datetime = get_flextable_defaults()$fmt_datetime, na_str = get_flextable_defaults()$na_str, nan_str = get_flextable_defaults()$nan_str, prefix = "", suffix = "" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection.} \item{fmt_datetime}{see \code{\link[=strptime]{strptime()}}} \item{na_str, nan_str}{string to be used for NA and NaN values} \item{prefix, suffix}{string to be used as prefix or suffix} } \description{ Format datetime cells in a flextable. } \examples{ dat <- data.frame( z = Sys.time() + (1:3) * 24, w = Sys.Date() - (1:3) * 24 ) ft <- flextable(dat) ft <- colformat_datetime(x = ft) ft <- autofit(ft) ft } \seealso{ Other cells formatters: \code{\link{colformat_char}()}, \code{\link{colformat_date}()}, \code{\link{colformat_double}()}, \code{\link{colformat_image}()}, \code{\link{colformat_int}()}, \code{\link{colformat_lgl}()}, \code{\link{colformat_num}()}, \code{\link{set_formatter}()} } \concept{cells formatters} flextable/man/add_footer_lines.Rd0000644000176200001440000000251314515157112016565 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_footer_lines} \alias{add_footer_lines} \title{Add labels as new rows in the footer} \usage{ add_footer_lines(x, values = character(0), top = FALSE) } \arguments{ \item{x}{a \code{flextable} object} \item{values}{a character vector or a call to \code{\link[=as_paragraph]{as_paragraph()}} to get formated content, each element will be added as a new row.} \item{top}{should the row be inserted at the top or the bottom. Default to TRUE.} } \description{ Add labels as new rows in the footer, where all columns are merged. This is a sugar function to be used when you need to add labels in the footer, a footnote for example. } \examples{ ft_1 <- flextable(head(iris)) ft_1 <- add_footer_lines(ft_1, values = c("blah 1", "blah 2") ) ft_1 } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/merge_h_range.Rd0000644000176200001440000000172514476430471016063 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/merge_flextable.R \name{merge_h_range} \alias{merge_h_range} \title{Rowwise merge of a range of columns} \usage{ merge_h_range(x, i = NULL, j1 = NULL, j2 = NULL, part = "body") } \arguments{ \item{x}{\code{flextable} object} \item{i}{selected rows} \item{j1, j2}{selected columns that will define the range of columns to merge.} \item{part}{partname of the table where merge has to be done.} } \description{ Merge flextable columns into a single one for each selected rows. All columns must be consecutive. } \examples{ ft <- flextable(head(mtcars), cwidth = .5) ft <- theme_box(ft) ft <- merge_h_range(ft, i = ~ cyl == 6, j1 = "am", j2 = "carb") ft <- flextable::align(ft, i = ~ cyl == 6, align = "center") ft } \seealso{ Other flextable merging function: \code{\link{merge_at}()}, \code{\link{merge_h}()}, \code{\link{merge_none}()}, \code{\link{merge_v}()} } \concept{flextable merging function} flextable/man/as_bracket.Rd0000644000176200001440000000303214476430470015367 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_bracket} \alias{as_bracket} \title{Chunk with values in brackets} \usage{ as_bracket(..., sep = ", ", p = "(", s = ")") } \arguments{ \item{...}{text and column names} \item{sep}{separator} \item{p}{prefix, default to '('} \item{s}{suffix, default to ')'} } \description{ The function is producing a chunk by pasting values and add the result in brackets. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("Species", "Sepal", "Petal") ) ft <- set_header_labels(ft, Sepal = "Sepal", Petal = "Petal") ft <- compose(ft, j = "Sepal", value = as_paragraph(as_bracket(Sepal.Length, Sepal.Width)) ) ft <- compose(ft, j = "Petal", value = as_paragraph(as_bracket(Petal.Length, Petal.Width)) ) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/fmt_avg_dev.Rd0000644000176200001440000000176214476430471015563 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_avg_dev} \alias{fmt_avg_dev} \title{Format content for mean and sd} \usage{ fmt_avg_dev(avg, dev, digit1 = 1, digit2 = 1) } \arguments{ \item{avg, dev}{mean and sd values} \item{digit1, digit2}{number of digits to show when printing 'mean' and 'sd'.} } \description{ The function formats means and standard deviations as \code{mean (sd)}. } \examples{ library(flextable) df <- data.frame(avg = 1:3 * 3, sd = 1:3) ft_1 <- flextable(df, col_keys = "avg") ft_1 <- mk_par( x = ft_1, j = 1, part = "body", value = as_paragraph(fmt_avg_dev(avg = avg, dev = sd)) ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_2stats}()}, \code{\link{fmt_dbl}()}, \code{\link{fmt_header_n}()}, \code{\link{fmt_int}()}, \code{\link{fmt_n_percent}()}, \code{\link{fmt_pct}()} } \concept{text formatter functions} flextable/man/flextable.Rd0000644000176200001440000000700714255321756015246 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable.R \name{flextable} \alias{flextable} \alias{qflextable} \title{flextable creation} \usage{ flextable( data, col_keys = names(data), cwidth = 0.75, cheight = 0.25, defaults = list(), theme_fun = theme_booktabs ) qflextable(data) } \arguments{ \item{data}{dataset} \item{col_keys}{columns names/keys to display. If some column names are not in the dataset, they will be added as blank columns by default.} \item{cwidth, cheight}{initial width and height to use for cell sizes in inches.} \item{defaults, theme_fun}{deprecated, use \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} instead.} } \description{ Create a flextable object with function \code{flextable}. \code{flextable} are designed to make tabular reporting easier for R users. Functions are available to let you format text, paragraphs and cells; table cells can be merge vertically or horizontally, row headers can easily be defined, rows heights and columns widths can be manually set or automatically computed. If working with 'R Markdown' documents, you should read about knitr chunk options in \code{\link[=knit_print.flextable]{knit_print.flextable()}} and about setting default values with \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}. } \section{Reuse frequently used parameters}{ Some default formatting properties are automatically applied to every flextable you produce. It is highly recommended to use this function because its use will minimize the code. For example, instead of calling the \code{fontsize()} function over and over again for each new flextable, set the font size default value by calling (before creating the flextables) \code{set_flextable_defaults(font.size = 11)}. This is also a simple way to have homogeneous arrays and make the documents containing them easier to read. You can change these default values with function \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}. You can reset them with function \code{\link[=init_flextable_defaults]{init_flextable_defaults()}}. You can access these values by calling \code{\link[=get_flextable_defaults]{get_flextable_defaults()}}. } \section{new lines and tabulations}{ The 'flextable' package will translate for you the new lines expressed in the form \verb{\\n} and the tabs expressed in the form \verb{\\t}. The new lines will be transformed into "soft-return", that is to say a simple carriage return and not a new paragraph. Tabs are different depending on the output format: \itemize{ \item HTML is using entity \emph{em space} \item Word - a Word 'tab' element \item PowerPoint - a PowerPoint 'tab' element \item latex - tag "\\quad " } } \section{flextable parts}{ A \code{flextable} is made of 3 parts: header, body and footer. Most functions have an argument named \code{part} that will be used to specify what part of of the table should be modified. } \section{qflextable}{ \code{qflextable} is a convenient tool to produce quickly a flextable for reporting where layout is fixed (see \code{\link[=set_table_properties]{set_table_properties()}}) and columns widths are adjusted with \code{\link[=autofit]{autofit()}}. } \examples{ ft <- flextable(head(mtcars)) ft } \seealso{ \code{\link[=style]{style()}}, \code{\link[=autofit]{autofit()}}, \code{\link[=theme_booktabs]{theme_booktabs()}}, \code{\link[=knit_print.flextable]{knit_print.flextable()}}, \code{\link[=compose]{compose()}}, \code{\link[=footnote]{footnote()}}, \code{\link[=set_caption]{set_caption()}} } flextable/man/add_footer.Rd0000644000176200001440000000432014515157112015371 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_footer} \alias{add_footer} \title{Add column values as new lines in footer} \usage{ add_footer(x, top = TRUE, ..., values = NULL) } \arguments{ \item{x}{a flextable object} \item{top}{should the rows be inserted at the top or the bottom.} \item{...}{named arguments (names are data colnames) of values to add. It is important to insert data of the same type as the original data, otherwise it will be transformed (probably into strings if you add a \code{character} where a \code{double} is expected). This makes possible to still format cell contents with the \verb{colformat_*} functions, for example \code{\link[=colformat_num]{colformat_num()}}.} \item{values}{a list of name-value pairs of labels or values, names should be existing col_key values. This argument can be used instead of \code{...} for programming purpose (If \code{values} is supplied argument \code{...} is ignored).} } \description{ The function adds a list of values to be inserted as new rows in the footer. The values are inserted in existing columns of the input data of the flextable. Rows can be inserted at the top or the bottom of the footer. If some columns are not provided, they will be replaced by \code{NA} and displayed as empty. } \examples{ new_row <- as.list(colMeans(iris[, -5])) new_row$Species <- "Means" formatter <- function(x) sprintf("\%.1f", x) ft <- flextable(data = head(iris)) ft <- add_footer(ft, values = new_row) # cosmetics ft <- compose( x = ft, j = 1:4, value = as_paragraph( as_chunk(., formatter = formatter) ), part = "footer", use_dot = TRUE ) ft <- align(ft, part = "footer", align = "right", j = 1:4) ft } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_header_row}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/htmltools_value.Rd0000644000176200001440000000252014515040434016502 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{htmltools_value} \alias{htmltools_value} \title{flextable as an 'HTML' object} \usage{ htmltools_value( x, ft.align = NULL, ft.shadow = NULL, extra_dependencies = NULL ) } \arguments{ \item{x}{a flextable object} \item{ft.align}{flextable alignment, supported values are 'left', 'center' and 'right'.} \item{ft.shadow}{deprecated.} \item{extra_dependencies}{a list of HTML dependencies to add in the HTML output.} } \value{ an object marked as \link{HTML} ready to be used within a call to \code{shiny::renderUI} for example. } \description{ get a \code{\link[=div]{div()}} from a flextable object. This can be used in a shiny application. For an output within "R Markdown" document, use \link{knit_print.flextable}. } \examples{ htmltools_value(flextable(iris[1:5, ])) } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/font.Rd0000644000176200001440000000507714411071536014243 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{font} \alias{font} \title{Set font} \usage{ font( x, i = NULL, j = NULL, fontname, part = "body", cs.family = fontname, hansi.family = fontname, eastasia.family = fontname ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{fontname}{single character value, the font family name. With Word and PowerPoint output, the value specifies the font to be used to format characters in the Unicode range (U+0000-U+007F).} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} \item{cs.family}{Optional font to be used to format characters in a complex script Unicode range. For example, Arabic text might be displayed using the "Arial Unicode MS" font. Used only with Word and PowerPoint outputs. Its default value is the value of \code{fontname}.} \item{hansi.family}{optional. Specifies the font to be used to format characters in a Unicode range which does not fall into one of the other categories. Used only with Word and PowerPoint outputs. Its default value is the value of \code{fontname}.} \item{eastasia.family}{optional font to be used to format characters in an East Asian Unicode range. For example, Japanese text might be displayed using the "MS Mincho" font. Used only with Word and PowerPoint outputs. Its default value is the value of \code{fontname}.} } \description{ Change font of selected rows and columns of a flextable. Fonts impact the readability and aesthetics of the table. Font families refer to a set of typefaces that share common design features, such as 'Arial' and 'Open Sans'. 'Google Fonts' is a popular library of free web fonts that can be easily integrated in flextable with function \code{\link[gdtools:register_gfont]{gdtools::register_gfont()}}. When output is HTML, the font will be automatically added in the HTML document. } \examples{ library(gdtools) fontname <- "Brush Script MT" if (font_family_exists(fontname)) { ft_1 <- flextable(head(iris)) ft_2 <- font(ft_1, fontname = fontname, part = "header") ft_2 <- font(ft_2, fontname = fontname, j = 5) ft_2 } } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/set_table_properties.Rd0000644000176200001440000001176714426532366017527 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable.R \name{set_table_properties} \alias{set_table_properties} \title{Global table properties} \usage{ set_table_properties( x, layout = "fixed", width = 0, align = "center", opts_html = list(), opts_word = list(), opts_pdf = list(), word_title = NULL, word_description = NULL ) } \arguments{ \item{x}{flextable object} \item{layout}{'autofit' or 'fixed' algorithm. Default to 'autofit'.} \item{width}{The parameter has a different effect depending on the output format. Users should consider it as a minimum width. In HTML, it is the minimum width of the space that the table should occupy. In Word, it is a preferred size and Word may decide not to strictly stick to it. It has no effect on PowerPoint and PDF output. Its default value is 0, as an effect, it only use necessary width to display all content. It is not used by the PDF output.} \item{align}{alignment in document (only Word, HTML and PDF), supported values are 'left', 'center' and 'right'.} \item{opts_html}{html options as a list. Supported elements are: \itemize{ \item 'extra_css': extra css instructions to be integrated with the HTML code of the table. \item 'scroll': NULL or a list if you want to add a scroll-box. \itemize{ \item Use an empty list to add an horizontal scroll. The with is fixed, corresponding to the container's width. \item If the list has a value named \code{height} it will be used as height and the scroll will happen also vertically. The height will be in pixel if numeric, if a string it should be a valid css measure. \item If the list has a value named \code{freeze_first_column} set to \code{TRUE}, the first column is set as a \emph{sticky} column. \item If the list has a value named \code{add_css} it will be used as extra css to add, .i.e: \verb{border:1px solid red;}. } }} \item{opts_word}{Word options as a list. Supported elements are: \itemize{ \item 'split': Word option 'Allow row to break across pages' can be activated when TRUE. \item 'keep_with_next': Word option 'keep rows together' is activated when TRUE. It avoids page break within tables. This is handy for small tables, i.e. less than a page height. }} \item{opts_pdf}{PDF options as a list. Supported elements are: \itemize{ \item 'tabcolsep': space between the text and the left/right border of its containing cell. \item 'arraystretch': height of each row relative to its default height, the default value is 1.5. \item 'float': type of floating placement in the PDF document, one of: \itemize{ \item 'none' (the default value), table is placed after the preceding paragraph. \item 'float', table can float to a place in the text where it fits best \item 'wrap-r', wrap text around the table positioned to the right side of the text \item 'wrap-l', wrap text around the table positioned to the left side of the text \item 'wrap-i', wrap text around the table positioned inside edge-near the binding \item 'wrap-o', wrap text around the table positioned outside edge-far from the binding } \item 'fonts_ignore': if TRUE, pdf-engine 'pdflatex' can be used instead of 'xelatex' or 'lualatex.' If pdflatex is used, fonts will be ignored because they are not supported by pdflatex, whereas with the xelatex and lualatex engines they are. \item 'caption_repeat': a boolean that indicates if the caption should be repeated along pages. Its default value is \code{TRUE}. \item 'default_line_color': default line color, restored globally after the flextable is produced. }} \item{word_title}{alternative text for Word table (used as title of the table)} \item{word_description}{alternative text for Word table (used as description of the table)} } \description{ Set table layout and table width. Default to fixed algorithm. If layout is fixed, column widths will be used to display the table; \code{width} is ignored. If layout is autofit, column widths will not be used; table width is used (as a percentage). } \note{ PowerPoint output ignore 'autofit layout'. } \examples{ library(flextable) ft_1 <- flextable(head(cars)) ft_1 <- autofit(ft_1) ft_2 <- set_table_properties(ft_1, width = .5, layout = "autofit") ft_2 ft_3 <- set_table_properties(ft_1, width = 1, layout = "autofit") # add scroll for HTML ---- set.seed(2) dat <- lapply(1:14, function(x) rnorm(n = 20)) dat <- setNames(dat, paste0("colname", 1:14)) dat <- as.data.frame(dat) ft_4 <- flextable(dat) ft_4 <- colformat_double(ft_4) ft_4 <- bg(ft_4, j = 1, bg = "#DDDDDD", part = "all") ft_4 <- bg(ft_4, i = 1, bg = "#DDDDDD", part = "header") ft_4 <- autofit(ft_4) ft_4 <- set_table_properties( x = ft_4, opts_html = list( scroll = list( height = "500px", freeze_first_column = TRUE ) ) ) ft_4 } \seealso{ Other flextable dimensions: \code{\link{autofit}()}, \code{\link{dim.flextable}()}, \code{\link{dim_pretty}()}, \code{\link{fit_to_width}()}, \code{\link{flextable_dim}()}, \code{\link{height}()}, \code{\link{hrule}()}, \code{\link{ncol_keys}()}, \code{\link{nrow_part}()}, \code{\link{width}()} } \concept{flextable dimensions} flextable/man/save_as_html.Rd0000644000176200001440000000342514515040434015733 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{save_as_html} \alias{save_as_html} \title{Save flextable objects in an 'HTML' file} \usage{ save_as_html(..., values = NULL, path, lang = "en", title = " ") } \arguments{ \item{...}{flextable objects, objects, possibly named. If named objects, names are used as titles.} \item{values}{a list (possibly named), each element is a flextable object. If named objects, names are used as titles. If provided, argument \code{...} will be ignored.} \item{path}{HTML file to be created} \item{lang}{language of the document using IETF language tags} \item{title}{page title} } \value{ a string containing the full name of the generated file } \description{ save a flextable in an 'HTML' file. This function is useful to save the flextable in 'HTML' file without using R Markdown (it is highly recommanded to use R Markdown instead). } \examples{ ft1 <- flextable(head(iris)) tf1 <- tempfile(fileext = ".html") if (rmarkdown::pandoc_available()) { save_as_html(ft1, path = tf1) # browseURL(tf1) } ft2 <- flextable(head(mtcars)) tf2 <- tempfile(fileext = ".html") if (rmarkdown::pandoc_available()) { save_as_html( `iris table` = ft1, `mtcars table` = ft2, path = tf2, title = "rhoooo" ) # browseURL(tf2) } } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/add_header_lines.Rd0000644000176200001440000000313314364612403016517 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_header_lines} \alias{add_header_lines} \title{Add labels as new rows in the header} \usage{ add_header_lines(x, values = character(0), top = TRUE) } \arguments{ \item{x}{a \code{flextable} object} \item{values}{a character vector or a call to \code{\link[=as_paragraph]{as_paragraph()}} to get formated content, each element will be added as a new row.} \item{top}{should the row be inserted at the top or the bottom. Default to TRUE.} } \description{ Add labels as new rows in the header, where all columns are merged. This is a sugar function to be used when you need to add labels in the header, most of the time it will be used to adding titles on the top rows of the flextable. } \examples{ # ex 1---- ft_1 <- flextable(head(iris)) ft_1 <- add_header_lines(ft_1, values = "blah blah") ft_1 <- add_header_lines(ft_1, values = c("blah 1", "blah 2")) ft_1 <- autofit(ft_1) ft_1 # ex 2---- ft01 <- fp_text_default(color = "red") ft02 <- fp_text_default(color = "orange") ref <- c("(1)", "(2)") pars <- as_paragraph( as_chunk(ref, props = ft02), " ", as_chunk(rep("My tailor is rich", length(ref)), props = ft01) ) ft_2 <- flextable(head(mtcars)) ft_2 <- add_header_lines(ft_2, values = pars, top = FALSE) ft_2 <- add_header_lines(ft_2, values = ref, top = TRUE) ft_2 <- add_footer_lines(ft_2, values = "blah", top = TRUE) ft_2 <- add_footer_lines(ft_2, values = pars, top = TRUE) ft_2 <- add_footer_lines(ft_2, values = ref, top = FALSE) ft_2 <- autofit(ft_2) ft_2 } \concept{functions that add rows in the table} flextable/man/print.flextable.Rd0000644000176200001440000000356014515040434016367 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{print.flextable} \alias{print.flextable} \title{flextable printing} \usage{ \method{print}{flextable}(x, preview = "html", align = "center", ...) } \arguments{ \item{x}{flextable object} \item{preview}{preview type, one of c("html", "pptx", "docx", "rtf", "pdf, "log"). When \code{"log"} is used, a description of the flextable is printed.} \item{align}{left, center (default) or right. Only for docx/html/pdf.} \item{...}{arguments for 'pdf_document' call when preview is "pdf".} } \description{ print a flextable object to format \code{html}, \code{docx}, \code{pptx} or as text (not for display but for informative purpose). This function is to be used in an interactive context. } \note{ When argument \code{preview} is set to \code{"docx"} or \code{"pptx"}, an external client linked to these formats (Office is installed) is used to edit a document. The document is saved in the temporary directory of the R session and will be removed when R session will be ended. When argument \code{preview} is set to \code{"html"}, an external client linked to these HTML format is used to display the table. If RStudio is used, the Viewer is used to display the table. Note also that a print method is used when flextable are used within R markdown documents. See \code{\link[=knit_print.flextable]{knit_print.flextable()}}. } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/dim.flextableGrob.Rd0000644000176200001440000000110114310450150016574 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/grid_grobs.R \name{dim.flextableGrob} \alias{dim.flextableGrob} \title{Get optimal width and height of a flextable grob} \usage{ \method{dim}{flextableGrob}(x) } \arguments{ \item{x}{a flextableGrob object} } \value{ a named list with two elements, \code{width} and \code{height}. Values are expressed in inches. } \description{ returns the optimal width and height for the grob, according to the grob generation parameters. } \examples{ ftab <- flextable(head(iris)) gr <- gen_grob(ftab) dim(gr) } flextable/man/as_flextable.grouped_data.Rd0000644000176200001440000000365414476430470020371 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable.R \name{as_flextable.grouped_data} \alias{as_flextable.grouped_data} \title{Transform a 'grouped_data' object into a flextable} \usage{ \method{as_flextable}{grouped_data}(x, col_keys = NULL, hide_grouplabel = FALSE, ...) } \arguments{ \item{x}{'grouped_data' object to be transformed into a "flextable"} \item{col_keys}{columns names/keys to display. If some column names are not in the dataset, they will be added as blank columns by default.} \item{hide_grouplabel}{if TRUE, group label will not be rendered, only level/value will be rendered.} \item{...}{unused argument} } \description{ Produce a flextable from a table produced by function \code{\link[=as_grouped_data]{as_grouped_data()}}. } \examples{ library(data.table) CO2 <- CO2 setDT(CO2) CO2$conc <- as.integer(CO2$conc) data_co2 <- dcast(CO2, Treatment + conc ~ Type, value.var = "uptake", fun.aggregate = mean ) data_co2 <- as_grouped_data(x = data_co2, groups = c("Treatment")) ft <- as_flextable(data_co2) ft <- add_footer_lines(ft, "dataset CO2 has been used for this flextable") ft <- add_header_lines(ft, "mean of carbon dioxide uptake in grass plants") ft <- set_header_labels(ft, conc = "Concentration") ft <- autofit(ft) ft <- width(ft, width = c(1, 1, 1)) ft } \seealso{ \code{\link[=as_grouped_data]{as_grouped_data()}} Other as_flextable methods: \code{\link{as_flextable.data.frame}()}, \code{\link{as_flextable.gam}()}, \code{\link{as_flextable.glm}()}, \code{\link{as_flextable.htest}()}, \code{\link{as_flextable.kmeans}()}, \code{\link{as_flextable.lm}()}, \code{\link{as_flextable.merMod}()}, \code{\link{as_flextable.pam}()}, \code{\link{as_flextable.summarizor}()}, \code{\link{as_flextable.table}()}, \code{\link{as_flextable.tabular}()}, \code{\link{as_flextable.tabulator}()}, \code{\link{as_flextable.xtable}()}, \code{\link{as_flextable}()} } \concept{as_flextable methods} flextable/man/fmt_int.Rd0000644000176200001440000000147414476430471014742 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summarizor.R \name{fmt_int} \alias{fmt_int} \title{Format numerical data as integer} \usage{ fmt_int(x) } \arguments{ \item{x}{numeric values} } \description{ The function formats numeric vectors as integer. } \examples{ library(flextable) df <- data.frame(zz = 1.23) ft_1 <- flextable(df) ft_1 <- mk_par( x = ft_1, j = 1, part = "body", value = as_paragraph(as_chunk(zz, formatter = fmt_int)) ) ft_1 <- autofit(ft_1) ft_1 } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}} Other text formatter functions: \code{\link{fmt_2stats}()}, \code{\link{fmt_avg_dev}()}, \code{\link{fmt_dbl}()}, \code{\link{fmt_header_n}()}, \code{\link{fmt_n_percent}()}, \code{\link{fmt_pct}()} } \concept{text formatter functions} flextable/man/theme_zebra.Rd0000644000176200001440000000421114364612403015550 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_zebra} \alias{theme_zebra} \title{Apply zebra theme} \usage{ theme_zebra( x, odd_header = "#CFCFCF", odd_body = "#EFEFEF", even_header = "transparent", even_body = "transparent" ) } \arguments{ \item{x}{a flextable object} \item{odd_header, odd_body, even_header, even_body}{odd/even colors for table header and body} } \description{ Apply theme zebra to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_zebra(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()} } \concept{functions related to themes} flextable/man/as_sup.Rd0000644000176200001440000000272014476430470014566 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_sup} \alias{as_sup} \title{Superscript chunk} \usage{ as_sup(x) } \arguments{ \item{x}{value, if a chunk, the chunk will be updated} } \description{ The function is producing a chunk with superscript vertical alignment. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \note{ This is a sugar function that ease the composition of complex labels made of different formattings. It should be used inside a call to \code{\link[=as_paragraph]{as_paragraph()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("dummy")) ft <- compose(ft, i = 1, j = "dummy", part = "header", value = as_paragraph( " anything ", as_sup("Sepal.Width") ) ) ft <- autofit(ft) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/gg_chunk.Rd0000644000176200001440000000465014476430471015066 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/chunk_images.R \name{gg_chunk} \alias{gg_chunk} \title{'ggplots' chunk wrapper} \usage{ gg_chunk(value, width = 1, height = 0.2, unit = "in", res = 300) } \arguments{ \item{value}{gg objects, stored in a list column; or a list of 'ggplot' objects.} \item{width, height}{size of the resulting png file.} \item{unit}{unit for width and height, one of "in", "cm", "mm".} \item{res}{resolution of the png image in ppi} } \description{ This function is used to insert mini gg plots into flextable with functions: \itemize{ \item \code{\link[=compose]{compose()}} and \code{\link[=as_paragraph]{as_paragraph()}}, \item \code{\link[=append_chunks]{append_chunks()}}, \item \code{\link[=prepend_chunks]{prepend_chunks()}}. } } \note{ This chunk option requires package officedown in a R Markdown context with Word output format. PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format. } \examples{ library(data.table) library(flextable) if (require("ggplot2")) { my_cor_plot <- function(x) { cols <- colnames(x)[sapply(x, is.numeric)] x <- x[, .SD, .SDcols = cols] cormat <- as.data.table(cor(x)) cormat$var1 <- colnames(cormat) cormat <- melt(cormat, id.vars = "var1", measure.vars = cormat$var1, variable.name = "var2", value.name = "correlation" ) ggplot(data = cormat, aes(x = var1, y = var2, fill = correlation)) + geom_tile() + coord_equal() + scale_fill_gradient2( low = "blue", mid = "white", high = "red", limits = c(-1, 1), guide = FALSE ) + theme_void() } z <- as.data.table(iris) z <- z[, list(gg = list(my_cor_plot(.SD))), by = "Species"] ft <- flextable(z) ft <- mk_par(ft, j = "gg", value = as_paragraph( gg_chunk(value = gg, width = 1, height = 1) ) ) ft } } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/as_i.Rd0000644000176200001440000000230314476430470014204 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_i} \alias{as_i} \title{Italic chunk} \usage{ as_i(x) } \arguments{ \item{x}{value, if a chunk, the chunk will be updated} } \description{ The function is producing a chunk with italic font. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. } \examples{ ft <- flextable(head(iris), col_keys = c("Sepal.Length", "dummy") ) ft <- compose(ft, j = "dummy", value = as_paragraph(as_i(Sepal.Length)) ) ft } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{as_word_field}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/flextable-package.Rd0000644000176200001440000000262514375477032016642 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable-package.R \docType{package} \name{flextable-package} \alias{flextable-package} \title{flextable: Functions for Tabular Reporting} \description{ The flextable package facilitates access to and manipulation of tabular reporting elements from R. The documentation of functions can be opened with command \code{help(package = "flextable")}. \code{flextable()} function is producing flexible tables where each cell can contain several chunks of text with their own set of formatting properties (bold, font color, etc.). Function \code{\link[=mk_par]{mk_par()}} lets customise text of cells. The \code{\link[=as_flextable]{as_flextable()}} function is used to transform specific objects into flextable objects. For example, you can transform a crosstab produced with the 'tables' package into a flextable which can then be formatted, annotated or augmented with footnotes. In order to reduce the homogenization efforts and the number of functions to be called, it is recommended to define formatting properties such as font, border color, number of decimals displayed which will then be applied by default. See \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} for more details. } \seealso{ \url{https://davidgohel.github.io/flextable/}, \url{https://ardata-fr.github.io/flextable-book/}, \code{\link[=flextable]{flextable()}} } flextable/man/fontsize.Rd0000644000176200001440000000207514411071536015131 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{fontsize} \alias{fontsize} \title{Set font size} \usage{ fontsize(x, i = NULL, j = NULL, size = 11, part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{size}{integer value (points)} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change font size of selected rows and columns of a flextable. } \examples{ ft <- flextable(head(iris)) ft <- fontsize(ft, size = 14, part = "header") ft <- fontsize(ft, size = 14, j = 2) ft <- fontsize(ft, size = 7, j = 3) ft } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()}, \code{\link{valign}()} } \concept{sugar functions for table style} flextable/man/gen_grob.Rd0000644000176200001440000001213314515040434015044 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/grid_grobs.R \name{gen_grob} \alias{gen_grob} \title{Convert a flextable to a grid grob object} \usage{ gen_grob( x, ..., fit = c("auto", "width", "fixed"), scaling = c("min", "full", "fixed"), wrapping = TRUE, autowidths = TRUE, just = NULL ) } \arguments{ \item{x}{A flextable object} \item{...}{Reserved for extra arguments} \item{fit}{Determines the fitting/scaling of the grob on its parent viewport. One of \code{auto}, \code{width}, \code{fixed}, \code{TRUE}, \code{FALSE}: \itemize{ \item \code{auto} or \code{TRUE} (default): The grob is resized to fit in the parent viewport. The table row heights and column widths are resized proportionally. \item \code{width}: The grob is resized horizontally to fit the width of the parent viewport. The column widths are resized proportionally. The row heights are unaffected and the table height may be smaller or larger than the height of the parent viewport. \item \code{fixed} or \code{FALSE}: The grob will have fixed dimensions, as determined by the column widths and the row heights. }} \item{scaling}{Determines the scaling of the table contents. One of \code{min}, \code{full}, \code{fixed}, \code{TRUE}, \code{FALSE}: \itemize{ \item \code{min} or \code{TRUE} (default): When the parent viewport is smaller than the necessary, the various content sizes (text font size, line width and image dimensions) will decrease accordingly so that the content can still fit. When the parent viewport is larger than the necessary, the content sizes will remain the same, they will not increase. \item \code{full}: Same as \code{min}, except that the content sizes are scaled fully, they will increase or decrease, according to the size of the drawing surface. \item \code{fixed} or \code{FALSE}: The content sizes will not be scaled. }} \item{wrapping}{Determines the soft wrapping (line breaking) method for the table cell contents. One of \code{TRUE}, \code{FALSE}: \itemize{ \item \code{TRUE}: Text content may wrap into separate lines at normal word break points (such as a space or tab character between two words) or at newline characters anywhere in the text content. If a word does not fit in the available cell width, then the text content may wrap at any character. Non-text content (such as images) is also wrapped into new lines, according to the available cell width. \item \code{FALSE}: Text content may wrap only with a newline character. Non-text content is not wrapped. } Superscript and subscript chunks do not wrap. Newline and tab characters are removed from these chunk types.} \item{autowidths}{If \code{TRUE} (default) the column widths are adjusted in order to fit the contents of the cells (taking into account the \code{wrapping} setting).} \item{just}{Justification of viewport layout, same as \code{just} argument in \code{\link[grid:grid.layout]{grid::grid.layout()}}. When set to \code{NULL} (default), it is determined according to the \code{fit} argument.} } \value{ a grob (gTree) object made with package \code{grid} } \description{ It uses Grid Graphics (package \code{grid}) to Convert a flextable into a grob object with scaling and text wrapping capabilities. This method can be used to insert a flextable inside a \code{ggplot2} plot, it can also be used with package 'patchwork' or 'cowplot' to combine ggplots and flextables into the same graphic. User can vary the size of the elements according to the size of the graphic window. The text behavior is controllable, user can decide to make the paragraphs (texts and images) distribute themselves correctly in the available space of the cell. It is possible to define resizing options, for example by using only the width, or by distributing the content so that it occupies the whole graphic space. It is also possible to freeze or not the size of the columns. It is not recommended to use this function for large tables because the calculations can be long. Limitations: equations (see \code{\link[=as_equation]{as_equation()}}) and hyperlinks (see \code{\link[=hyperlink_ftext]{hyperlink_ftext()}}) will not be displayed. } \section{size}{ The size of the flextable can be known by using the method \link[=dim.flextableGrob]{dim} on the grob. } \examples{ ft <- flextable(head(mtcars)) ft <- autofit(ft) gr <- gen_grob(ft) used_family <- get_flextable_defaults()$font.family if (gdtools::font_family_exists(used_family) && require("ragg")) { png_f <- tempfile(fileext = ".png") # get the size dims <- dim(gr) dims ragg::agg_png( filename = png_f, width = dims$width + .1, height = dims$height + .1, units = "in", res = 150 ) plot(gr) dev.off() } } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/valign.Rd0000644000176200001440000000224614411071536014550 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/styles.R \name{valign} \alias{valign} \title{Set vertical alignment} \usage{ valign(x, i = NULL, j = NULL, valign = "center", part = "body") } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{valign}{vertical alignment of paragraph within cell, one of "center" or "top" or "bottom".} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change vertical alignment of selected rows and columns of a flextable. } \examples{ ft_1 <- flextable(iris[c(1:3, 51:53, 101:103), ]) ft_1 <- theme_box(ft_1) ft_1 <- merge_v(ft_1, j = 5) ft_1 ft_2 <- valign(ft_1, j = 5, valign = "top", part = "all") ft_2 } \seealso{ Other sugar functions for table style: \code{\link{align}()}, \code{\link{bg}()}, \code{\link{bold}()}, \code{\link{color}()}, \code{\link{empty_blanks}()}, \code{\link{fontsize}()}, \code{\link{font}()}, \code{\link{highlight}()}, \code{\link{italic}()}, \code{\link{keep_with_next}()}, \code{\link{line_spacing}()}, \code{\link{padding}()}, \code{\link{rotate}()} } \concept{sugar functions for table style} flextable/man/shift_table.Rd0000644000176200001440000001231514476430471015562 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/clintables.R \name{shift_table} \alias{shift_table} \title{Create a shift table} \usage{ shift_table( x, cn_visit = "VISIT", cn_visit_num = "VISITNUM", cn_grade = "LBNRIND", cn_usubjid = "USUBJID", cn_lab_cat = NA_character_, cn_is_baseline = "LBBLFL", baseline_identifier = "Y", cn_treatment = NA_character_, grade_levels = c("LOW", "NORMAL", "HIGH"), grade_labels = c("Low", "Normal", "High") ) } \arguments{ \item{x}{Laboratory Tests Results data frame.} \item{cn_visit}{column name containing visit names, default to "VISIT".} \item{cn_visit_num}{column name containing visit numbers, default to "VISITNUM".} \item{cn_grade}{column name containing reference range indicators, default to "LBNRIND".} \item{cn_usubjid}{column name containing unique subject inditifiers, default to "USUBJID".} \item{cn_lab_cat}{column name containing lab tests or examination names, default to "LBTEST".} \item{cn_is_baseline}{column name containing baseline flags, default to "LBBLFL".} \item{baseline_identifier}{baseline flag value to use for baseline identification. Its default is "Y".} \item{cn_treatment}{column name containing treatment names, default to \code{NA}.} \item{grade_levels}{levels to use for reference range indicators} \item{grade_labels}{labels to use for reference range indicators} } \value{ the shift table as a data.frame. Additionnal elements are provided in attributes: \itemize{ \item "VISIT_N": count of unique subject id per visits, labs and eventually treatments. This element is supposed to be used as value for argument \code{hidden_data} of function \code{tabulator()}. \item "FUN_VISIT": a utility function to easily turn \emph{visit} column as a factor column. It should be applied after the shift table creation. \item "FUN_GRADE": a utility function to easily turn \emph{grade} column as a factor column. It adds "MISSING/Missing" and "SUM/Sum" at the end of the set of values specified in arguments \code{grade_levels} and \code{grade_labels}. It should be applied after the shift table creation. } } \description{ Create a shift table ready to be used with \code{tabulator()}. The function is transforming a dataset representing some 'Laboratory Tests Results' structured as \emph{CDISC clinical trial data sets} format to a dataset representing the shift table. Shift tables are tables used in clinical trial analysis. They show the progression of change from the baseline, with the progression often being along time; the number of subjects is displayed in different range (e.g. low, normal, or high) at baseline and at selected time points or intervals. } \examples{ \dontshow{ data.table::setDTthreads(1) } library(data.table) library(flextable) # data simulation ---- USUBJID <- sprintf("01-ABC-\%04.0f", 1:200) VISITS <- c("SCREENING 1", "WEEK 2", "MONTH 3") LBTEST <- c("Albumin", "Sodium") VISITNUM <- seq_along(VISITS) LBBLFL <- rep(NA_character_, length(VISITNUM)) LBBLFL[1] <- "Y" VISIT <- data.frame( VISIT = VISITS, VISITNUM = VISITNUM, LBBLFL = LBBLFL, stringsAsFactors = FALSE ) labdata <- expand.grid( USUBJID = USUBJID, LBTEST = LBTEST, VISITNUM = VISITNUM, stringsAsFactors = FALSE ) setDT(labdata) labdata <- merge(labdata, VISIT, by = "VISITNUM") subject_elts <- unique(labdata[, .SD, .SDcols = "USUBJID"]) subject_elts <- unique(subject_elts) subject_elts[, c("TREAT") := list( sample(x = c("Treatment", "Placebo"), size = .N, replace = TRUE) )] subject_elts[, c("TREAT") := list( factor(.SD$TREAT, levels = c("Treatment", "Placebo")) )] setDF(subject_elts) labdata <- merge(labdata, subject_elts, by = "USUBJID", all.x = TRUE, all.y = FALSE ) labdata[, c("LBNRIND") := list( sample( x = c("LOW", "NORMAL", "HIGH"), size = .N, replace = TRUE, prob = c(.03, .9, .07) ) )] setDF(labdata) # shift table calculation ---- SHIFT_TABLE <- shift_table( x = labdata, cn_visit = "VISIT", cn_grade = "LBNRIND", cn_usubjid = "USUBJID", cn_lab_cat = "LBTEST", cn_treatment = "TREAT", cn_is_baseline = "LBBLFL", baseline_identifier = "Y", grade_levels = c("LOW", "NORMAL", "HIGH") ) # get attrs for post treatment ---- SHIFT_TABLE_VISIT <- attr(SHIFT_TABLE, "VISIT_N") visit_as_factor <- attr(SHIFT_TABLE, "FUN_VISIT") range_as_factor <- attr(SHIFT_TABLE, "FUN_GRADE") # post treatments ---- SHIFT_TABLE$VISIT <- visit_as_factor(SHIFT_TABLE$VISIT) SHIFT_TABLE$BASELINE <- range_as_factor(SHIFT_TABLE$BASELINE) SHIFT_TABLE$LBNRIND <- range_as_factor(SHIFT_TABLE$LBNRIND) SHIFT_TABLE_VISIT$VISIT <- visit_as_factor(SHIFT_TABLE_VISIT$VISIT) # tabulator ---- my_format <- function(z) { formatC(z * 100, digits = 1, format = "f", flag = "0", width = 4 ) } tab <- tabulator( x = SHIFT_TABLE, hidden_data = SHIFT_TABLE_VISIT, row_compose = list( VISIT = as_paragraph(VISIT, "\n(N=", N_VISIT, ")") ), rows = c("LBTEST", "VISIT", "BASELINE"), columns = c("TREAT", "LBNRIND"), `n` = as_paragraph(N), `\%` = as_paragraph(as_chunk(PCT, formatter = my_format)) ) # as_flextable ---- ft_1 <- as_flextable( x = tab, separate_with = "VISIT", label_rows = c( LBTEST = "Lab Test", VISIT = "Visit", BASELINE = "Reference Range Indicator" ) ) ft_1 } \concept{tools for clinical reporting} flextable/man/proc_freq.Rd0000644000176200001440000000240314410655214015243 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/proc_freq.R \name{proc_freq} \alias{proc_freq} \title{Frequency table} \usage{ proc_freq( x, row = character(), col = character(), include.row_percent = TRUE, include.column_percent = TRUE, include.table_percent = TRUE, weight = character(), ... ) } \arguments{ \item{x}{a \code{data.frame} object containing variable(s) to use for counts.} \item{row}{\code{characer} column names for row} \item{col}{\code{characer} column names for column} \item{include.row_percent}{\code{boolean} whether to include the row percents; defaults to \code{TRUE}} \item{include.column_percent}{\code{boolean} whether to include the column percents; defaults to \code{TRUE}} \item{include.table_percent}{\code{boolean} whether to include the table percents; defaults to \code{TRUE}} \item{weight}{\code{character} column name for weight} \item{...}{unused arguments} } \description{ This function compute a one or two way contingency table and create a flextable from the result. The function is largely inspired by "PROC FREQ" from "SAS" and was written with the intent to make it as compact as possible. } \examples{ proc_freq(mtcars, "vs", "gear") proc_freq(mtcars, "gear", "vs", weight = "wt") } flextable/man/save_as_docx.Rd0000644000176200001440000000350014515040434015716 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{save_as_docx} \alias{save_as_docx} \title{Save flextable objects in a 'Word' file} \usage{ save_as_docx(..., values = NULL, path, pr_section = NULL, align = "center") } \arguments{ \item{...}{flextable objects, objects, possibly named. If named objects, names are used as titles.} \item{values}{a list (possibly named), each element is a flextable object. If named objects, names are used as titles. If provided, argument \code{...} will be ignored.} \item{path}{Word file to be created} \item{pr_section}{a \link{prop_section} object that can be used to define page layout such as orientation, width and height.} \item{align}{left, center (default) or right.} } \value{ a string containing the full name of the generated file } \description{ sugar function to save flextable objects in an Word file. } \examples{ tf <- tempfile(fileext = ".docx") library(officer) ft1 <- flextable(head(iris)) save_as_docx(ft1, path = tf) ft2 <- flextable(head(mtcars)) sect_properties <- prop_section( page_size = page_size( orient = "landscape", width = 8.3, height = 11.7 ), type = "continuous", page_margins = page_mar() ) save_as_docx( `iris table` = ft1, `mtcars table` = ft2, path = tf, pr_section = sect_properties ) } \seealso{ \code{\link[=paginate]{paginate()}} Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{flextable_to_rmd}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/fp_text_default.Rd0000644000176200001440000000646014476430471016457 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/defaults.R \name{fp_text_default} \alias{fp_text_default} \title{Text formatting properties} \usage{ fp_text_default( color = flextable_global$defaults$font.color, font.size = flextable_global$defaults$font.size, bold = FALSE, italic = FALSE, underlined = FALSE, font.family = flextable_global$defaults$font.family, cs.family = NULL, eastasia.family = NULL, hansi.family = NULL, vertical.align = "baseline", shading.color = "transparent" ) } \arguments{ \item{color}{font color - a single character value specifying a valid color (e.g. "#000000" or "black").} \item{font.size}{font size (in point) - 0 or positive integer value.} \item{bold}{is bold} \item{italic}{is italic} \item{underlined}{is underlined} \item{font.family}{single character value. Specifies the font to be used to format characters in the Unicode range (U+0000-U+007F).} \item{cs.family}{optional font to be used to format characters in a complex script Unicode range. For example, Arabic text might be displayed using the "Arial Unicode MS" font.} \item{eastasia.family}{optional font to be used to format characters in an East Asian Unicode range. For example, Japanese text might be displayed using the "MS Mincho" font.} \item{hansi.family}{optional. Specifies the font to be used to format characters in a Unicode range which does not fall into one of the other categories.} \item{vertical.align}{single character value specifying font vertical alignments. Expected value is one of the following : default \code{'baseline'} or \code{'subscript'} or \code{'superscript'}} \item{shading.color}{shading color - a single character value specifying a valid color (e.g. "#000000" or "black").} } \description{ Create a \code{\link[=fp_text]{fp_text()}} object that uses defaut values defined in the flextable it applies to. \code{fp_text_default()} is a handy function that will allow you to specify certain formatting values to be applied to a piece of text, the formatting values that are not specified will simply be the existing formatting values. For example, if you set the text in the cell to red previously, using the code \code{fp_text_default(bold = TRUE)}, the formatting will be 'bold' but it will also be 'red'. On the other hand, the \code{fp_text()} function forces you to specify all the parameters, so we strongly recommend working with \code{fp_text_default()} which was created to replace the use of the former. See also \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} to modify flextable defaults formatting properties. } \examples{ library(flextable) set_flextable_defaults( font.size = 11, font.color = "#303030", padding = 3, table.layout = "autofit" ) z <- flextable(head(cars)) z <- compose( x = z, i = ~ speed < 6, j = "speed", value = as_paragraph( as_chunk("slow... ", props = fp_text_default(color = "red")), as_chunk(speed, props = fp_text_default(italic = TRUE)) ) ) z init_flextable_defaults() } \seealso{ \code{\link[=as_chunk]{as_chunk()}}, \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}}, \code{\link[=prepend_chunks]{prepend_chunks()}} Other functions for defining formatting properties: \code{\link{fp_border_default}()} } \concept{functions for defining formatting properties} flextable/man/surround.Rd0000644000176200001440000000457614127421352015160 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{surround} \alias{surround} \title{Set borders for a selection of cells} \usage{ surround( x, i = NULL, j = NULL, border = NULL, border.top = NULL, border.bottom = NULL, border.left = NULL, border.right = NULL, part = "body" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{border}{border (shortcut for top, bottom, left and right)} \item{border.top}{border top} \item{border.bottom}{border bottom} \item{border.left}{border left} \item{border.right}{border right} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ Highlight specific cells with borders. To set borders for the whole table, use \code{\link[=border_outer]{border_outer()}}, \code{\link[=border_inner_h]{border_inner_h()}} and \code{\link[=border_inner_v]{border_inner_v()}}. All the following functions also support the row and column selector \code{i} and \code{j}: \itemize{ \item \code{\link[=hline]{hline()}}: set bottom borders (inner horizontal) \item \code{\link[=vline]{vline()}}: set right borders (inner vertical) \item \code{\link[=hline_top]{hline_top()}}: set the top border (outer horizontal) \item \code{\link[=vline_left]{vline_left()}}: set the left border (outer vertical) } } \examples{ library(officer) library(flextable) # cell to highlight vary_i <- 1:3 vary_j <- 1:3 std_border <- fp_border(color = "orange") ft <- flextable(head(iris)) ft <- border_remove(x = ft) ft <- border_outer(x = ft, border = std_border) for (id in seq_along(vary_i)) { ft <- bg( x = ft, i = vary_i[id], j = vary_j[id], bg = "yellow" ) ft <- surround( x = ft, i = vary_i[id], j = vary_j[id], border.left = std_border, border.right = std_border, part = "body" ) } ft <- autofit(ft) ft # # render # print(ft, preview = "pptx") # print(ft, preview = "docx") # print(ft, preview = "pdf") # print(ft, preview = "html") } \seealso{ Other borders management: \code{\link{border_inner_h}()}, \code{\link{border_inner_v}()}, \code{\link{border_inner}()}, \code{\link{border_outer}()}, \code{\link{border_remove}()}, \code{\link{hline_bottom}()}, \code{\link{hline_top}()}, \code{\link{hline}()}, \code{\link{vline_left}()}, \code{\link{vline_right}()}, \code{\link{vline}()} } \concept{borders management} flextable/man/flextable_to_rmd.Rd0000644000176200001440000000273114515040434016577 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/printers.R \name{flextable_to_rmd} \alias{flextable_to_rmd} \title{flextable raw code} \usage{ flextable_to_rmd(x, ...) } \arguments{ \item{x}{a flextable object} \item{...}{unused argument} } \description{ Print openxml, latex or html code of a flextable. The function is particularly useful when you want to generate flextable in a loop from a R Markdown document. Inside R Markdown document, chunk option \code{results} must be set to 'asis'. See \link{knit_print.flextable} for more details. } \examples{ \dontrun{ library(rmarkdown) if (pandoc_available() && pandoc_version() > numeric_version("2")) { demo_loop <- system.file( package = "flextable", "examples/rmd", "loop_with_flextable.Rmd" ) rmd_file <- tempfile(fileext = ".Rmd") file.copy(demo_loop, to = rmd_file, overwrite = TRUE) render( input = rmd_file, output_format = "html_document", output_file = "loop_with_flextable.html" ) } } } \seealso{ Other flextable print function: \code{\link{as_raster}()}, \code{\link{df_printer}()}, \code{\link{gen_grob}()}, \code{\link{htmltools_value}()}, \code{\link{knit_print.flextable}()}, \code{\link{plot.flextable}()}, \code{\link{print.flextable}()}, \code{\link{save_as_docx}()}, \code{\link{save_as_html}()}, \code{\link{save_as_image}()}, \code{\link{save_as_pptx}()}, \code{\link{save_as_rtf}()}, \code{\link{to_html.flextable}()} } \concept{flextable print function} flextable/man/add_header_row.Rd0000644000176200001440000000437214515157112016221 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_header_row} \alias{add_header_row} \title{Add header labels} \usage{ add_header_row(x, top = TRUE, values = character(0), colwidths = integer(0)) } \arguments{ \item{x}{a flextable object} \item{top}{should the row be inserted at the top or the bottom. Default to TRUE.} \item{values}{values to add, a character vector (as header rows contains only character values/columns), a list or a call to \code{\link[=as_paragraph]{as_paragraph()}}.} \item{colwidths}{the number of columns used for each label} } \description{ Add a row of new columns labels in header part. Labels can be spanned along multiple columns, as merged cells. Labels are associated with a number of columns to merge that default to one if not specified. In this case, you have to make sure that the number of labels is equal to the number of columns displayed. The function can add only one single row by call. Labels can also be formatted with \code{\link[=as_paragraph]{as_paragraph()}}. } \examples{ library(flextable) ft01 <- fp_text_default(color = "red") ft02 <- fp_text_default(color = "orange") pars <- as_paragraph( as_chunk(c("(1)", "(2)"), props = ft02), " ", as_chunk(c( "My tailor is rich", "My baker is rich" ), props = ft01) ) ft_1 <- flextable(head(mtcars)) ft_1 <- add_header_row(ft_1, values = pars, colwidths = c(5, 6), top = FALSE ) ft_1 <- add_header_row(ft_1, values = pars, colwidths = c(3, 8), top = TRUE ) ft_1 ft_2 <- flextable(head(airquality)) ft_2 <- add_header_row(ft_2, values = c("Measure", "Time"), colwidths = c(4, 2), top = TRUE ) ft_2 <- theme_box(ft_2) ft_2 } \seealso{ \code{\link[=flextable]{flextable()}}, \code{\link[=set_caption]{set_caption()}} Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/body_replace_flextable_at_bkm.Rd0000644000176200001440000000135714440663650021273 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/body_add_flextable.R \name{body_replace_flextable_at_bkm} \alias{body_replace_flextable_at_bkm} \title{Add flextable at boorkmark location in a Word document} \usage{ body_replace_flextable_at_bkm( x, bookmark, value, align = "center", split = FALSE ) } \arguments{ \item{x}{an rdocx object} \item{bookmark}{bookmark id} \item{value}{\code{flextable} object} \item{align}{left, center (default) or right.} \item{split}{set to TRUE if you want to activate Word option 'Allow row to break across pages'.} } \description{ Use this function if you want to replace a paragraph containing a bookmark with a flextable. As a side effect, the bookmark will be lost. } flextable/man/theme_tron_legacy.Rd0000644000176200001440000000372514364612403016764 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_tron_legacy} \alias{theme_tron_legacy} \title{Apply tron legacy theme} \usage{ theme_tron_legacy(x) } \arguments{ \item{x}{a flextable object} } \description{ Apply theme tron legacy to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_tron_legacy(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/add_latex_dep.Rd0000644000176200001440000000131214375473105016045 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/latex_str.R \name{add_latex_dep} \alias{add_latex_dep} \title{Add latex dependencies} \usage{ add_latex_dep(float = FALSE, wrapfig = FALSE) } \arguments{ \item{float}{load package 'float'} \item{wrapfig}{load package 'wrapfig'} } \description{ Manually add flextable latex dependencies to the knitr session via \code{\link[=knit_meta_add]{knit_meta_add()}}. When enabling caching in 'R Markdown' documents for PDF output, the flextable cached result is used directly. Call \code{add_latex_dep()} in a non cached chunk so that flextable latex dependencies are added to knitr metadata. } \examples{ add_latex_dep() } \keyword{internal} flextable/man/theme_tron.Rd0000644000176200001440000000366214364612403015440 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_tron} \alias{theme_tron} \title{Apply tron theme} \usage{ theme_tron(x) } \arguments{ \item{x}{a flextable object} } \description{ Apply theme tron to a flextable } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_tron(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_alafoli}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/labelizor.Rd0000644000176200001440000000246014476430471015261 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/compose.R \name{labelizor} \alias{labelizor} \title{Change displayed labels} \usage{ labelizor(x, j = NULL, labels, part = "all") } \arguments{ \item{x}{a flextable object} \item{j}{columns selection} \item{labels}{a named vector whose names will be used to identify values to replace and values will be used as labels.} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ The function replace text values in a flextable with labels. The labels are defined with character named vector. The function is not written to be fast but to be handy. It does not replace the values in the underlying dataset but replace the defined content in the flextable (as defined with \code{\link[=compose]{compose()}}). } \examples{ \dontshow{ data.table::setDTthreads(1) } z <- summarizor( x = CO2[-c(1, 4)], by = "Treatment", overall_label = "Overall" ) ft_1 <- as_flextable(z, separate_with = "variable") ft_1 <- labelizor( x = ft_1, j = c("stat"), labels = c(Missing = "Kouign amann") ) ft_1 <- labelizor( x = ft_1, j = c("variable"), labels = toupper ) ft_1 } \seealso{ \code{\link[=mk_par]{mk_par()}}, \code{\link[=append_chunks]{append_chunks()}}, \code{\link[=prepend_chunks]{prepend_chunks()}} } flextable/man/merge_at.Rd0000644000176200001440000000143514476430471015062 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/merge_flextable.R \name{merge_at} \alias{merge_at} \title{Merge flextable cells into a single one} \usage{ merge_at(x, i = NULL, j = NULL, part = "body") } \arguments{ \item{x}{\code{flextable} object} \item{i, j}{columns and rows to merge} \item{part}{partname of the table where merge has to be done.} } \description{ Merge flextable cells into a single one. All rows and columns must be consecutive. } \examples{ ft_merge <- flextable(head(mtcars), cwidth = .5) ft_merge <- merge_at(ft_merge, i = 1:2, j = 1:2) ft_merge } \seealso{ Other flextable merging function: \code{\link{merge_h_range}()}, \code{\link{merge_h}()}, \code{\link{merge_none}()}, \code{\link{merge_v}()} } \concept{flextable merging function} flextable/man/tabulator_colnames.Rd0000644000176200001440000000563614375471155017166 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/as_flextable_tabulator.R \name{tabulator_colnames} \alias{tabulator_colnames} \title{Column keys of tabulator objects} \usage{ tabulator_colnames(x, columns, ..., type = NULL) } \arguments{ \item{x}{a \code{\link[=tabulator]{tabulator()}} object} \item{columns}{column names to look for} \item{...}{any filter conditions that use variables names, the same than the argument \code{columns} of function \code{\link[=tabulator]{tabulator()}} (\code{tabulator(columns = c("col1", "col2"))}).} \item{type}{the type of column to look for, it can be: \itemize{ \item 'columns': visible columns, corresponding to names provided in the '...' arguments of your call to 'tabulator()'. \item 'hidden': unvisible columns, corresponding to names of the original dataset columns. \item 'rows': visible columns used as 'row' content \item 'rows_supp': visible columns used as 'rows_supp' content \item NULL: any type of column }} } \description{ The function provides a way to get column keys associated with the flextable corresponding to a \code{\link[=tabulator]{tabulator()}} object. It helps in customizing or programing with \code{tabulator}. The function is using column names from the original dataset, eventually filters and returns the names corresponding to the selection. } \examples{ library(flextable) cancer_dat <- data.frame( count = c( 9L, 5L, 1L, 2L, 2L, 1L, 9L, 3L, 1L, 10L, 2L, 1L, 1L, 2L, 0L, 3L, 2L, 1L, 1L, 2L, 0L, 12L, 4L, 1L, 7L, 3L, 1L, 5L, 5L, 3L, 10L, 4L, 1L, 4L, 2L, 0L, 3L, 1L, 0L, 4L, 4L, 2L, 42L, 28L, 19L, 26L, 19L, 11L, 12L, 10L, 7L, 10L, 5L, 6L, 5L, 0L, 3L, 4L, 3L, 3L, 1L, 2L, 3L ), risktime = c( 157L, 77L, 21L, 139L, 68L, 17L, 126L, 63L, 14L, 102L, 55L, 12L, 88L, 50L, 10L, 82L, 45L, 8L, 76L, 42L, 6L, 134L, 71L, 22L, 110L, 63L, 18L, 96L, 58L, 14L, 86L, 42L, 10L, 66L, 35L, 8L, 59L, 32L, 8L, 51L, 28L, 6L, 212L, 130L, 101L, 136L, 72L, 63L, 90L, 42L, 43L, 64L, 21L, 32L, 47L, 14L, 21L, 39L, 13L, 14L, 29L, 7L, 10L ), time = rep(as.character(1:7), 3), histology = rep(as.character(1:3), 21), stage = rep(as.character(1:3), each = 21) ) datasup_first <- data.frame( time = factor(1:7, levels = 1:7), zzz = runif(7) ) z <- tabulator(cancer_dat, rows = "time", columns = c("histology", "stage"), datasup_first = datasup_first, n = as_paragraph(as_chunk(count)) ) j <- tabulator_colnames( x = z, type = "columns", columns = c("n"), stage \%in\% 1 ) src <- tabulator_colnames( x = z, type = "hidden", columns = c("count"), stage \%in\% 1 ) if (require("scales")) { colourer <- col_numeric( palette = c("wheat", "red"), domain = c(0, 45) ) ft_1 <- as_flextable(z) ft_1 <- bg( ft_1, bg = colourer, part = "body", j = j, source = src ) ft_1 } } \seealso{ \code{\link[=tabulator]{tabulator()}}, \code{\link[=as_flextable.tabulator]{as_flextable.tabulator()}} } flextable/man/regulartable.Rd0000644000176200001440000000141214255321756015743 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/flextable.R \name{regulartable} \alias{regulartable} \title{flextable old functions} \usage{ regulartable(data, col_keys = names(data), cwidth = 0.75, cheight = 0.25) } \arguments{ \item{data}{dataset} \item{col_keys}{columns names/keys to display. If some column names are not in the dataset, they will be added as blank columns by default.} \item{cwidth, cheight}{initial width and height to use for cell sizes in inches.} } \description{ The function is maintained for compatibility with old codes mades by users but be aware it produces the same exact object than \code{\link[=flextable]{flextable()}}. This function should be deprecated then removed in the next versions. } \keyword{internal} flextable/man/as_word_field.Rd0000644000176200001440000000605514476430470016102 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/05_content.R \name{as_word_field} \alias{as_word_field} \title{'Word' computed field} \usage{ as_word_field(x, props = NULL, width = 0.1, height = 0.15, unit = "in") } \arguments{ \item{x}{computed field strings} \item{props}{text properties (see \code{\link[=fp_text_default]{fp_text_default()}} or \code{\link[officer:fp_text]{officer::fp_text()}}) object to be used to format the text. If not specified, it will use the default text properties of the cell(s).} \item{width, height}{size computed field} \item{unit}{unit for width and height, one of "in", "cm", "mm".} } \description{ This function is used to insert 'Word' computed field into flextable. It is used to add it to the content of a cell of the flextable with the functions \code{\link[=compose]{compose()}}, \code{\link[=append_chunks]{append_chunks()}} or \code{\link[=prepend_chunks]{prepend_chunks()}}. This has only effect on 'Word' output. If you want to condition its execution only for Word output, you can use it in the post processing step (see \code{set_flextable_defaults(post_process_docx = ...)}) \strong{Do not forget to update the computed field in Word}. Fields are defined but are not computed, this computing is an operation that has to be made by 'Microsoft Word' (select all text and hit \code{F9} when on mac os). } \examples{ library(flextable) # define some default values ---- set_flextable_defaults(font.size = 22, border.color = "gray") # an example with append_chunks ---- pp_docx <- function(x) { x <- add_header_lines(x, "Page ") x <- append_chunks( x = x, i = 1, part = "header", j = 1, as_word_field(x = "Page") ) align(x, part = "header", align = "left") } ft_1 <- flextable(cars) ft_1 <- autofit(ft_1) ft_1 <- pp_docx(ft_1) ## or: # set_flextable_defaults(post_process_docx = pp_docx) ## to prevent this line addition when output is not docx # print(ft_1, preview = "docx") # an example with compose ---- library(officer) ft_2 <- flextable(head(cars)) ft_2 <- add_footer_lines(ft_2, "temp text") ft_2 <- compose( x = ft_2, part = "footer", i = 1, j = 1, as_paragraph( "p. ", as_word_field(x = "Page", width = .05), " on ", as_word_field(x = "NumPages", width = .05) ) ) ft_2 <- autofit(ft_2, part = c("header", "body")) doc <- read_docx() doc <- body_add_flextable(doc, ft_2) doc <- body_add_break(doc) doc <- body_add_flextable(doc, ft_2) outfile <- print(doc, target = tempfile(fileext = ".docx")) # reset default values ---- init_flextable_defaults() } \seealso{ Other chunk elements for paragraph: \code{\link{as_bracket}()}, \code{\link{as_b}()}, \code{\link{as_chunk}()}, \code{\link{as_equation}()}, \code{\link{as_highlight}()}, \code{\link{as_image}()}, \code{\link{as_i}()}, \code{\link{as_sub}()}, \code{\link{as_sup}()}, \code{\link{colorize}()}, \code{\link{gg_chunk}()}, \code{\link{grid_chunk}()}, \code{\link{hyperlink_text}()}, \code{\link{linerange}()}, \code{\link{lollipop}()}, \code{\link{minibar}()}, \code{\link{plot_chunk}()} } \concept{chunk elements for paragraph} flextable/man/theme_alafoli.Rd0000644000176200001440000000366214364612403016065 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{theme_alafoli} \alias{theme_alafoli} \title{Apply alafoli theme} \usage{ theme_alafoli(x) } \arguments{ \item{x}{a flextable object} } \description{ Apply alafoli theme } \section{behavior}{ Theme functions are not like 'ggplot2' themes. They are applied to the existing table \strong{immediately}. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called. That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows). If you want to automatically apply a theme function to each flextable, you can use the \code{theme_fun} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}; be aware that this theme function is applied as the last instruction when calling \code{flextable()} - so if you add headers or footers to the array, they will not be formatted with the theme. You can also use the \code{post_process_html} argument of \code{\link[=set_flextable_defaults]{set_flextable_defaults()}} (or \code{post_process_pdf}, \code{post_process_docx}, \code{post_process_pptx}) to specify a theme to be applied systematically before the \code{flextable()} is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement. } \examples{ ft <- flextable(head(airquality)) ft <- theme_alafoli(ft) ft } \seealso{ Other functions related to themes: \code{\link{get_flextable_defaults}()}, \code{\link{set_flextable_defaults}()}, \code{\link{theme_apa}()}, \code{\link{theme_booktabs}()}, \code{\link{theme_box}()}, \code{\link{theme_tron_legacy}()}, \code{\link{theme_tron}()}, \code{\link{theme_vader}()}, \code{\link{theme_vanilla}()}, \code{\link{theme_zebra}()} } \concept{functions related to themes} flextable/man/border.Rd0000644000176200001440000000415214476430470014552 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/borders.R \name{border} \alias{border} \title{Cell borders update} \usage{ border( x, i = NULL, j = NULL, border = NULL, border.top = NULL, border.bottom = NULL, border.left = NULL, border.right = NULL, part = "body" ) } \arguments{ \item{x}{a flextable object} \item{i}{rows selection} \item{j}{columns selection} \item{border}{border (shortcut for top, bottom, left and right)} \item{border.top}{border top} \item{border.bottom}{border bottom} \item{border.left}{border left} \item{border.right}{border right} \item{part}{partname of the table (one of 'all', 'body', 'header', 'footer')} } \description{ change borders of selected rows and columns of a flextable. This function is not to be used by end user (it requires careful settings to avoid overlapping borders) but only for programming purposes. If you need to add borders, use instead other functions: These set borders for the whole table : \code{\link[=border_outer]{border_outer()}}, \code{\link[=border_inner_h]{border_inner_h()}} and \code{\link[=border_inner_v]{border_inner_v()}}. To add horizontal or vertical lines in the table at specific location, use: \itemize{ \item \code{\link[=hline]{hline()}}: set bottom borders (inner horizontal) \item \code{\link[=vline]{vline()}}: set right borders (inner vertical) } To add following horizontal or vertical lines at beginning or end of the table, use: \itemize{ \item \code{\link[=hline_top]{hline_top()}}: set the top border (outer horizontal) \item \code{\link[=hline_bottom]{hline_bottom()}}: set the bottom border (outer horizontal) \item \code{\link[=vline_left]{vline_left()}}: set the left border (outer vertical) \item \code{\link[=vline_right]{vline_right()}}: set the right border (outer vertical) } If you want to highlight specific cells with some borders, use \code{\link[=surround]{surround()}}. } \note{ pdf and pptx outputs do not support \code{border()} usage. } \examples{ library(officer) ftab <- flextable(head(mtcars)) ftab <- border(ftab, border.top = fp_border(color = "orange")) ftab } \keyword{internal} flextable/man/add_header.Rd0000644000176200001440000000517114515157112015330 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/augment_rows.R \name{add_header} \alias{add_header} \title{Add column values as new lines in header} \usage{ add_header(x, top = TRUE, ..., values = NULL) } \arguments{ \item{x}{a flextable object} \item{top}{should the rows be inserted at the top or the bottom.} \item{...}{named arguments (names are data colnames) of values to add. It is important to insert data of the same type as the original data, otherwise it will be transformed (probably into strings if you add a \code{character} where a \code{double} is expected). This makes possible to still format cell contents with the \verb{colformat_*} functions, for example \code{\link[=colformat_num]{colformat_num()}}.} \item{values}{a list of name-value pairs of labels or values, names should be existing col_key values. This argument can be used instead of \code{...} for programming purpose (If \code{values} is supplied argument \code{...} is ignored).} } \description{ The function adds a list of values to be inserted as new rows in the header. The values are inserted in existing columns of the input data of the flextable. Rows can be inserted at the top or the bottom of the header. If some columns are not provided, they will be replaced by \code{NA} and displayed as empty. \if{html}{\out{ add_header illustration }} } \note{ when repeating values, they can be merged together with function \code{\link[=merge_h]{merge_h()}} and \code{\link[=merge_v]{merge_v()}}. } \examples{ library(flextable) fun <- function(x) { paste0( c("min: ", "max: "), formatC(range(x)) ) } new_row <- list( Sepal.Length = fun(iris$Sepal.Length), Sepal.Width = fun(iris$Sepal.Width), Petal.Width = fun(iris$Petal.Width), Petal.Length = fun(iris$Petal.Length) ) ft_1 <- flextable(data = head(iris)) ft_1 <- add_header(ft_1, values = new_row, top = FALSE) ft_1 <- append_chunks(ft_1, part = "header", i = 2, ) ft_1 <- theme_booktabs(ft_1, bold_header = TRUE) ft_1 <- align(ft_1, align = "center", part = "all") ft_1 } \seealso{ Other functions for row and column operations in a flextable: \code{\link{add_body_row}()}, \code{\link{add_body}()}, \code{\link{add_footer_lines}()}, \code{\link{add_footer_row}()}, \code{\link{add_footer}()}, \code{\link{add_header_row}()}, \code{\link{delete_columns}()}, \code{\link{delete_part}()}, \code{\link{delete_rows}()}, \code{\link{separate_header}()}, \code{\link{set_header_footer_df}}, \code{\link{set_header_labels}()} } \concept{functions for row and column operations in a flextable} flextable/man/fp_border_default.Rd0000644000176200001440000000250214476430471016741 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/defaults.R \name{fp_border_default} \alias{fp_border_default} \title{Border formatting properties} \usage{ fp_border_default( color = flextable_global$defaults$border.color, style = "solid", width = flextable_global$defaults$border.width ) } \arguments{ \item{color}{border color - single character value (e.g. "#000000" or "black")} \item{style}{border style - single character value : "none" or "solid" or "dotted" or "dashed"} \item{width}{border width - an integer value : 0>= value} } \description{ Create a \code{\link[=fp_border]{fp_border()}} object that uses defaut values defined in flextable defaults formatting properties, i.e. default border color (see \code{\link[=set_flextable_defaults]{set_flextable_defaults()}}). } \examples{ library(flextable) set_flextable_defaults( border.color = "orange" ) z <- flextable(head(cars)) z <- theme_vanilla(z) z <- vline( z, j = 1, part = "all", border = officer::fp_border() ) z <- vline( z, j = 2, part = "all", border = fp_border_default() ) z init_flextable_defaults() } \seealso{ \code{\link[=hline]{hline()}}, \code{\link[=vline]{vline()}} Other functions for defining formatting properties: \code{\link{fp_text_default}()} } \concept{functions for defining formatting properties} flextable/DESCRIPTION0000644000176200001440000000625614515315543013745 0ustar liggesusersPackage: flextable Type: Package Title: Functions for Tabular Reporting Version: 0.9.4 Authors@R: c( person("David", "Gohel", role = c("aut", "cre"), email = "david.gohel@ardata.fr"), person(given = "ArData", role = "cph"), person("Clementine", "Jager", role = "ctb"), person("Panagiotis", "Skintzos", role = "aut", email = "panagiotis.skintzos@ardata.fr"), person("Quentin", "Fazilleau", role = "ctb"), person("Maxim", "Nazarov", role = "ctb", comment = "rmarkdown for docx output"), person("Titouan", "Robert", role = "ctb"), person("Michael", "Barrowman", role = "ctb", comment = "inline footnotes"), person("Atsushi", "Yasumoto", role = "ctb", comment = "support for bookdown cross reference"), person("Paul", "Julian", role = "ctb", comment = "support for gam objects"), person("Sean", "Browning", role = "ctb", comment = "work on footnote positioning system"), person("Rémi", "Thériault", role = "ctb", comment = c(ORCID = "0000-0003-4315-6788", ctb = "theme_apa")), person("Samuel", "Jobert", role = "ctb", comment = "work on pagination") ) Description: Use a grammar for creating and customizing pretty tables. The following formats are supported: 'HTML', 'PDF', 'RTF', 'Microsoft Word', 'Microsoft PowerPoint' and R 'Grid Graphics'. 'R Markdown', 'Quarto' and the package 'officer' can be used to produce the result files. The syntax is the same for the user regardless of the type of output to be produced. A set of functions allows the creation, definition of cell arrangement, addition of headers or footers, formatting and definition of cell content with text and or images. The package also offers a set of high-level functions that allow tabular reporting of statistical models and the creation of complex cross tabulations. License: GPL-3 Imports: stats, utils, grDevices, graphics, grid, rmarkdown, knitr, htmltools, rlang, ragg, officer (>= 0.6.2), gdtools (>= 0.3.3), xml2, data.table (>= 1.13.0), uuid (>= 0.1-4) RoxygenNote: 7.2.3 Suggests: testthat (>= 2.1.0), magick, equatags, commonmark, ggplot2, scales, doconv (>= 0.3.0), xtable, tables (>= 0.9.17), broom, broom.mixed, mgcv, cluster, lme4, nlme, bookdown (>= 0.34), pdftools, officedown, pkgdown (>= 2.0.0), webshot2, svglite Encoding: UTF-8 URL: https://ardata-fr.github.io/flextable-book/, https://davidgohel.github.io/flextable/ BugReports: https://github.com/davidgohel/flextable/issues VignetteBuilder: knitr NeedsCompilation: no Packaged: 2023-10-22 20:47:44 UTC; davidgohel Author: David Gohel [aut, cre], ArData [cph], Clementine Jager [ctb], Panagiotis Skintzos [aut], Quentin Fazilleau [ctb], Maxim Nazarov [ctb] (rmarkdown for docx output), Titouan Robert [ctb], Michael Barrowman [ctb] (inline footnotes), Atsushi Yasumoto [ctb] (support for bookdown cross reference), Paul Julian [ctb] (support for gam objects), Sean Browning [ctb] (work on footnote positioning system), Rémi Thériault [ctb] (, theme_apa), Samuel Jobert [ctb] (work on pagination) Maintainer: David Gohel Repository: CRAN Date/Publication: 2023-10-22 22:00:03 UTC flextable/build/0000755000176200001440000000000014515305156013324 5ustar liggesusersflextable/build/vignette.rds0000644000176200001440000000031614515305156015663 0ustar liggesusers‹‹àb```b`afd`b2™… 1# 'æÉ/K-*ËL-× ÊMA“ã-ÎÌKWHËI­(ILÊIE“æ…kÍ(ÉÍA“Y- æCÄ€… Iž5/17µM»KjAj^ HøvýŒÿÑ´px§V–çÁô ¨aƒªaqË:joHf œÃàâe2¡»Ã|÷så—ëÁüÀ òmøèMÎI,F÷(WJbI¢^ZP?ÈÝ63º1ªflextable/tests/0000755000176200001440000000000014374162731013372 5ustar liggesusersflextable/tests/testthat/0000755000176200001440000000000014515315543015230 5ustar liggesusersflextable/tests/testthat/test-cell-content.R0000644000176200001440000001147114476427034020730 0ustar liggesuserscontext("cell content") library(utils) library(xml2) library(officer) library(rmarkdown) test_that("void works as expected", { ftab <- flextable(head(mtcars)) ftab <- void(ftab, part = "all") expect_true(all(flextable:::fortify_run(ftab)$txt %in% "")) }) z <- structure( list( name = c("Matthieu Guillou-Poulain", "Noémi Pasquier d'Vaillant", "Honoré L'Delannoy", "Alice L'Bonneau", "Adrien Dupuy"), birthday = structure(c(25463, 7642, 13950, 23805, 21243), class = "Date"), n_children = c(4, 4, 4, 4, 2), weight = c(83.6459598876536, 61.8819103203714, NA, 52.6329895108938, 53.5817482229322), height = c(163.589849524116, 171.920463847195, 169.474969328653, 164.460310102575, 167.755981621553), n_peanuts = c(821107L, 774581L, 721301L, 1116933L, 1009038L), eye_color = structure(c(2L, 1L, 1L, 1L, 1L), .Label = c("dark", "green"), class = "factor") ), row.names = c(NA, -5L), class = "data.frame" ) z$timestamp <- as.POSIXct("2011-01-01 09:09:09") test_that("flextable_defaults values for cell content", { set_flextable_defaults( decimal.mark = ",", big.mark = " ", digits = 1, na_str = "NA", fmt_date = "%d %m %Y", fmt_datetime = "%d/%m/%Y %H:%M:%S" ) ft <- flextable(z) expected <- c( "name", "birthday", "n_children", "weight", "height", "n_peanuts", "eye_color", "timestamp", "Matthieu Guillou-Poulain", "19 09 2039", "4", "83,64596", "163,5898", "821 107", "green", "01/01/2011 09:09:09", "Noémi Pasquier d'Vaillant", "04 12 1990", "4", "61,88191", "171,9205", "774 581", "dark", "01/01/2011 09:09:09", "Honoré L'Delannoy", "12 03 2008", "4", "NA", "169,4750", "721 301", "dark", "01/01/2011 09:09:09", "Alice L'Bonneau", "06 03 2035", "4", "52,63299", "164,4603", "1 116 933", "dark", "01/01/2011 09:09:09", "Adrien Dupuy", "29 02 2028", "2", "53,58175", "167,7560", "1 009 038", "dark", "01/01/2011 09:09:09" ) expect_equivalent(object = flextable:::fortify_run(ft)$txt, expected) init_flextable_defaults() }) test_that("colformat_* functions", { dat <- data.frame( letters1 = c("a", "b", "b", "c"), letters2 = c("d", "e", "b", "b"), number = 1:4 * pi, count = as.integer(1:4), is_something = c(TRUE, FALSE, TRUE, FALSE), dt = as.POSIXct("2011-01-01 09:09:09") - 1:4, date = as.Date("2011-02-23") + 1:4, stringsAsFactors = FALSE ) ft <- flextable(dat) ft <- colformat_char(x = ft, prefix = "-", suffix = "-") ft <- colformat_date(x = ft, fmt_date = "%d/%m/%Y", prefix = "-", suffix = "-") ft <- colformat_datetime(x = ft, fmt_date = "%d/%m/%Y %H%M%S", prefix = "-", suffix = "-") ft <- colformat_double( x = ft, big.mark = "", decimal.mark = ",", digits = 3, prefix = "-", suffix = "-" ) ft <- colformat_int(x = ft, prefix = "-", suffix = "-") ft <- colformat_lgl(x = ft, true = "OUI", false = "NON", prefix = "-", suffix = "-") expected <- c( "letters1", "letters2", "number", "count", "is_something", "dt", "date", "-a-", "-d-", "-3,142-", "-1-", "-OUI-", "-01/01/2011 090908-", "-24/02/2011-", "-b-", "-e-", "-6,283-", "-2-", "-NON-", "-01/01/2011 090907-", "-25/02/2011-", "-b-", "-b-", "-9,425-", "-3-", "-OUI-", "-01/01/2011 090906-", "-26/02/2011-", "-c-", "-b-", "-12,566-", "-4-", "-NON-", "-01/01/2011 090905-", "-27/02/2011-" ) expect_equivalent(object = flextable:::fortify_run(ft)$txt, expected) ft <- colformat_num(x = ft, big.mark = "", decimal.mark = ".", prefix = "+", suffix = "+") expected <- c( "letters1", "letters2", "number", "count", "is_something", "dt", "date", "-a-", "-d-", "+3.141593+", "+1+", "-OUI-", "-01/01/2011 090908-", "-24/02/2011-", "-b-", "-e-", "+6.283185+", "+2+", "-NON-", "-01/01/2011 090907-", "-25/02/2011-", "-b-", "-b-", "+9.424778+", "+3+", "-OUI-", "-01/01/2011 090906-", "-26/02/2011-", "-c-", "-b-", "+12.566371+", "+4+", "-NON-", "-01/01/2011 090905-", "-27/02/2011-" ) expect_equivalent(object = flextable:::fortify_run(ft)$txt, expected) }) test_that("append and prepend chunks structure", { ftab <- flextable(head(cars, n = 3)) ftab <- append_chunks(ftab, j = 1, as_chunk(" Samurai"), colorize(as_i(" Shodown"), color = "magenta") ) expect_equal(flextable:::fortify_run(ftab)$txt, expected = c( "speed", "dist", "4", " Samurai", " Shodown", "2", "4", " Samurai", " Shodown", "10", "7", " Samurai", " Shodown", "4" ) ) ftab <- flextable(head(cars, n = 3)) ftab <- prepend_chunks(ftab, j = 1, as_chunk("Samurai"), colorize(as_i(" Shodown "), color = "magenta") ) expect_equal(flextable:::fortify_run(ftab)$txt, expected = c( "speed", "dist", "Samurai", " Shodown ", "4", "2", "Samurai", " Shodown ", "4", "10", "Samurai", " Shodown ", "7", "4" ) ) }) flextable/tests/testthat/test-latex.R0000644000176200001440000000046014476427041017450 0ustar liggesuserscontext("latex table structure") test_that("white spaces are protected", { ft <- flextable(data.frame(x = "")) ft <- delete_part(ft, part = "header") ft <- mk_par(ft, 1, 1, as_paragraph("foo", " ", "bar")) str <- flextable:::gen_raw_latex(ft) expect_true(grepl("{\\ }", str, fixed = TRUE)) }) flextable/tests/testthat/test-padding.R0000644000176200001440000000164314476427044017750 0ustar liggesuserscontext("check paddings") library(utils) library(xml2) test_that("padding overwrite all paddings", { ft <- flextable(data.frame(a = c("", ""), stringsAsFactors = FALSE)) ft <- padding(ft, padding = 5) new_paddings <- c( ft$body$styles$pars$padding.bottom$data[, ], ft$body$styles$pars$padding.top$data[, ], ft$body$styles$pars$padding.left$data[, ], ft$body$styles$pars$padding.right$data[, ] ) new_paddings <- unique(new_paddings) expect_equal(new_paddings, 5) }) test_that("padding overwrite all paddings but not missing", { ft <- flextable(iris) ft <- padding(ft, padding = 5, padding.top = 20) new_paddings <- c( ft$body$styles$pars$padding.bottom$data[, ], ft$body$styles$pars$padding.top$data[, ], ft$body$styles$pars$padding.left$data[, ], ft$body$styles$pars$padding.right$data[, ] ) new_paddings <- unique(new_paddings) expect_equal(new_paddings, c(5, 20)) }) flextable/tests/testthat/test-proc-freq.R0000644000176200001440000000462614410655214020232 0ustar liggesuserscontext("check proc_freq") library(utils) library(xml2) p <- structure(list( lengths = c(9894L, 104L, 1L, 1L), values = c("No", "Yes", NA, NA) ), class = "rle") o <- structure(list( lengths = c(9641L, 252L, 1L, 23L, 81L, 1L, 1L), values = c("No", "Yes", NA, "No", "Yes", "No", NA) ), class = "rle") dat <- data.frame( p = inverse.rle(p), o = inverse.rle(o) ) full_dump_txt <- c( "o", "", "p", "p", "p", "p", "o", "", "No", "Yes", "Missing", "Total", "No", "Count", "9,641 (96.4%)", "", "23 (0.2%)", "", "1 (0.0%)", "", "9,665 (96.7%)", "", "No", "Mar. pct", " (1)", "", "97.4% ; 99.8%", "", "22.1% ; 0.2%", "", "50.0% ; 0.0%", "", "", "Yes", "Count", "252 (2.5%)", "", "81 (0.8%)", "", "", "", "333 (3.3%)", "", "Yes", "Mar. pct", "", "2.5% ; 75.7%", "", "77.9% ; 24.3%", "", "", "", "", "Missing", "Count", "1 (0.0%)", "", "", "", "1 (0.0%)", "", "2 (0.0%)", "", "Missing", "Mar. pct", "", "0.0% ; 50.0%", "", "", "", "50.0% ; 50.0%", "", "", "Total", "Count", "9,894 (98.9%)", "", "104 (1.0%)", "", "2 (0.0%)", "", "10,000 (100.0%)", "", " (1)", " Columns and rows percentages", " (1)", " (1)", " (1)", " (1)", " (1)" ) single_dump_txt <- c( "o", "Count", "Percent", "No", "9,665", "96.7%", "Yes", "333", "3.3%", "Missing", "2", "0.0%", "Total", "10,000", "100.0%" ) count_only_dump_txt <- c( "o", "p", "p", "p", "p", "o", "No", "Yes", "Missing", "Total", "No", "9,641", "", "23", "", "1", "", "9,665", "", "Yes", "252", "", "81", "", "", "", "333", "", "Missing", "1", "", "", "", "1", "", "2", "", "Total", "9,894", "", "104", "", "2", "", "10,000", "" ) test_that("proc_freq executes without errors", { dummy_df <- data.frame( values = rep(letters[1:3], each = 2), groups = rep(letters[1:3], each = 2), stringsAsFactors = FALSE ) ft <- proc_freq(dummy_df, "values", "groups") expect_equivalent(class(ft), "flextable") }) test_that("proc_freq content", { ft <- proc_freq(dat, row = "o", col = "p") expect_equal(flextable:::fortify_run(ft)$txt, full_dump_txt) ft <- proc_freq(dat, row = "o") expect_equal(flextable:::fortify_run(ft)$txt, single_dump_txt) ft <- proc_freq(dat, row = "o", col = "p", include.table_percent = FALSE, include.row_percent = FALSE, include.column_percent = FALSE ) expect_equal(flextable:::fortify_run(ft)$txt, count_only_dump_txt) expect_error(proc_freq(dat)) }) flextable/tests/testthat/test-pptx-tables.R0000644000176200001440000000315714476427045020610 0ustar liggesuserscontext("ppt table structure") library(utils) library(xml2) library(officer) test_that("row height is valid", { ft <- flextable(head(iris)) pptx_file <- "test.pptx" doc <- read_pptx() doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme") doc <- ph_with(doc, value = ft, location = ph_location_type(type = "body")) doc <- print(doc, target = pptx_file) main_folder <- file.path(getwd(), "pptx_folder") unzip(pptx_file, exdir = main_folder) slide_file <- file.path(main_folder, "/ppt/slides/slide1.xml") doc <- read_xml(slide_file) nodes <- xml_find_all(doc, "//p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr") h_values <- sapply(nodes, xml_attr, attr = "h") h_values <- as.integer(h_values) expect_true(all(is.finite(h_values))) expect_true(all(h_values > 0)) unlink(main_folder, recursive = TRUE, force = TRUE) unlink(pptx_file, force = TRUE) }) test_that("location is correct", { ft <- flextable(head(iris)) pptx_file <- tempfile(fileext = ".pptx") doc <- read_pptx() doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme") doc <- ph_with(doc, value = ft, location = ph_location(left = 0, top = 0)) doc <- print(doc, target = pptx_file) main_folder <- file.path(getwd(), "pptx_folder") unpack_folder(file = pptx_file, folder = main_folder) slide_file <- file.path(main_folder, "/ppt/slides/slide1.xml") doc <- read_xml(slide_file) node <- xml_find_first(doc, "//p:graphicFrame/p:xfrm/a:off") expect_equal(xml_attr(node, "x"), "0") expect_equal(xml_attr(node, "y"), "0") unlink(main_folder, recursive = TRUE, force = TRUE) }) flextable/tests/testthat/test-footers.R0000644000176200001440000000311214476427036020015 0ustar liggesuserscontext("check footers") library(xml2) library(officer) test_that("add_footer", { data_ref <- structure( list( Sepal.Length = c("Sepal", "s", "(cm)"), Sepal.Width = c("Sepal", "", "(cm)"), Petal.Length = c("Petal", "", "(cm)"), Petal.Width = c("Petal", "", "(cm)"), Species = c("Species", "", "(cm)") ), .Names = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species"), row.names = c(NA, -3L), class = "data.frame" ) ft <- flextable(iris[1:6, ]) ft <- add_footer( ft, Sepal.Length = "Sepal", Sepal.Width = "Sepal", Petal.Length = "Petal", Petal.Width = "Petal", Species = "Species" ) ft <- add_footer(ft, Sepal.Length = "s", top = FALSE) ft <- add_footer( ft, Sepal.Length = "(cm)", Sepal.Width = "(cm)", Petal.Length = "(cm)", Petal.Width = "(cm)", Species = "(cm)", top = FALSE ) has_ <- flextable:::fortify_content( ft$footer$content, default_chunk_fmt = ft$footer$styles$text )$txt expect_equal(has_, as.character(unlist(data_ref))) ft <- flextable(iris[1:6, ]) ft <- add_footer_row( ft, values = c("Sepal", "Petal", "Species"), colwidths = c(2, 2, 1) ) ft <- add_footer_lines(ft, "s", top = FALSE) ft <- add_footer_row(ft, values = "(cm)", colwidths = 5, top = FALSE) has_ <- flextable:::fortify_content( ft$footer$content, default_chunk_fmt = ft$footer$styles$text )$txt ref <- c( "Sepal", "s", "(cm)", "Sepal", "s", "(cm)", "Petal", "s", "(cm)", "Petal", "s", "(cm)", "Species", "s", "(cm)" ) expect_equal(has_, ref) }) flextable/tests/testthat/test-link.R0000644000176200001440000000305414311317344017262 0ustar liggesuserscontext("check hyperlink") library(xml2) library(officer) data <- data.frame( code = c("X01", "X02"), name = c("X Number 1", "X Number 2"), stringsAsFactors = FALSE ) url_base <- "https://example.com?/path&project=%s" ft <- flextable(data) ft <- mk_par( x = ft, j = ~code, value = as_paragraph( hyperlink_text(code, url = sprintf(url_base, code)) ) ) test_that("URL are preserved in docx", { outfile <- tempfile(fileext = ".docx") save_as_docx(ft, path = outfile) doc <- read_docx(path = outfile) body <- docx_body_xml(doc) rid <- xml_attr(xml_find_all(body, "//w:hyperlink"), "id") rels <- doc$doc_obj$rel_df() urls <- rels[rels$id %in% rid, "target"] expect_equivalent(urls, sprintf(url_base, data$code)) }) test_that("URL are preserved in pptx", { outfile <- tempfile(fileext = ".pptx") save_as_pptx(ft, path = outfile) doc <- read_pptx(path = outfile) xml_slide <- doc$slide$get_slide(1)$get() rid <- xml_attr(xml_find_all(xml_slide, "//a:hlinkClick"), "id") rels <- doc$slide$get_slide(1)$rel_df() urls <- rels[rels$id %in% rid, "target"] expect_equivalent(urls, sprintf(url_base, data$code)) }) test_that("URL are preserved in html", { str_ <- flextable:::gen_raw_html(ft) str_ <- gsub("", "", str_) str_ <- gsub("", "", str_) str_ <- gsub("