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

Down Chevron

Install

install.packages('tables')

Monthly Downloads

11,660

Version

0.9.17

License

GPL-2

Maintainer

Last Published

May 2nd, 2023

Functions in tables (0.9.17)