Learn R Programming

⚠️There's a newer version (0.9.33) of this package.Take me there.

tables

The goal of tables is to compute and display complex tables of summary statistics.

Output may be in LaTeX, HTML, plain text, or an R matrix for further processing.

Installation

You can install the release version of orientlib using

install.packages("tables")

You can install the development version of tables from GitHub with:

# install.packages("devtools")
devtools::install_github("dmurdoch/tables")

Example

This is a basic example which shows you how to solve a common problem:

library(tables)

# In an R Markdown document, you don't want each table
# to output the HTML document header, so turn 
# off that option:

table_options(htmloptions(head=FALSE))

X <- rnorm(125, sd=100)
Group <- factor(sample(letters[1:5], 125, rep=TRUE))
tab <- tabular( Group ~ 
                  (N=1) +
                  Format(digits=2)*X*
                    ((Mean=mean) +
                     Heading("Std Dev")*sd) 
              )

# To print in plain text:
tab
#>                        
#>           X            
#>  Group N  Mean  Std Dev
#>  a     27  14.2  95.1  
#>  b     22   0.2  78.5  
#>  c     31  34.1 100.4  
#>  d     22  12.1 114.5  
#>  e     23  19.8  92.8

# To format in HTML:
toHTML(tab)

To generate LaTeX code:

cat(toLatex(tab)$text) #> \begin{tabular}{lccc} #> \hline #> & & \multicolumn{2}{c}{X} \ #> Group & N & Mean & \multicolumn{1}{c}{Std Dev} \ #> \hline #> a & $27$ & $\phantom{0}14.2$ & $\phantom{0}95.1$ \ #> b & $22$ & $\phantom{00}0.2$ & $\phantom{0}78.5$ \ #> c & $31$ & $\phantom{0}34.1$ & $100.4$ \ #> d & $22$ & $\phantom{0}12.1$ & $114.5$ \ #> e & $23$ & $\phantom{0}19.8$ & $\phantom{0}92.8$ \ #> \hline #> \end{tabular}

Copy Link

Version

Install

install.packages('tables')

Monthly Downloads

27,839

Version

0.9.17

License

GPL-2

Maintainer

Duncan Murdoch

Last Published

May 2nd, 2023

Functions in tables (0.9.17)

knit_print.tabular

Custom printing of tabular objects.
PlusMinus

Generate x +/- y terms in table.
as.matrix.tabular

Convert tabular object to matrix
as.tabular

Convert matrix or dataframe to tabular object.
Paste

Generate terms to paste values together in table.
RowFactor

Use a variable as a factor to give rows in a table.
Percent

Pseudo-function to compute a statistic relative to a reference set.
table_options

Set or query options for the table formatting.
latexTable

Create table in full table environment
latexNumeric

Process numeric LaTeX or HTML values.
write.csv.tabular

Write table to file in CSV or other format.
tabular

Compute complex table
latex.tabular

Display a tabular object using LaTeX.
toKable

Convert tabular object to knitr_kable format.
matrix_form.tabular

Transform tabular object to matrices printable by formatters package
useGroupLabels

Format table with groups of lines
HTMLfootnotes

Construct footnotes
Justify

Justify pseudo-function
AllObs

Display all observations in a table.
Arguments

Arguments pseudo-function
Literal

Insert a literal entry into a table margin.
All

Include all columns of a dataframe.
DropEmpty

DropEmpty pseudo-function
Format

Format pseudo-function
Heading

Heading pseudo-function
Hline

Add a horizontal line to a LaTeX table.
labelSubset

Add a label to a logical vector.
labels

Retrieve or modify the row or column labels.
html.tabular

Display a tabular object using HTML.