With {tabularise} you should be able to obtain publication-ready (rich-formatted) tabular output from different R objects. It uses and enhances the {flextable} package to build these tables and allow to output them in HTML, LaTeX/PDF, Word or PowerPoint. See https://www.sciviews.org/tabularise for more details.
{tabularise} is not available from CRAN yet. You should install it from the SciViews R-Universe. The {equatags} and {equatiomatic} packages are optional, but they are useful to display equations, both inline in R Markdown/Quarto documents and in {tabularise} tables. The {data.io} package is useful too because it manages labels and units that {chart} uses. To install those three packages and their dependencies, run the following command in R:
install.packages(c('tabularise', 'equatags', 'equatiomatic', 'data.io'),
repos = c('https://sciviews.r-universe.dev', 'https://cloud.r-project.org'))
You can also install the latest development version of {tabularise}. Make sure you have the {remotes} R package installed:
# install.packages("remotes")
remotes::install_github("SciViews/tabularise")
Let’s take the well-known iris
data frame, to which we add labels and
units.
data("iris")
# Add labels and units
iris <- data.io::labelise(iris,
label = list(
Sepal.Length = "Sepal length", Sepal.Width = "Sepal width",
Petal.Length = "Petal length", Petal.Width = "Petal width",
Species = "Iris species"),
units = list(
Sepal.Length = "cm", Sepal.Width = "cm",
Petal.Length = "cm", Petal.Width = "cm"))
#> Registered S3 method overwritten by 'data.io':
#> method from
#> $.subsettable_type svMisc
Once the labels and units have been added to our data frame, the
tabularise()
function uses them automatically in the tables it
produces.
library(tabularise)
tabularise$headtail(iris) # or tabularise(iris, type = "headtail")
{tabularise} is a central package used by several other packages in the
SciViews universe to format its tabular outputs. Various methods are
available for tabularise()
and they are further enhanced by other
packages, such as {inferit} and
{modelit}.
Please note that the {tabularise} package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.