README.md

R-CMD-check

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)
    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 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}



Try the tables package in your browser

Any scripts or data that you put into this service are public.

tables documentation built on May 3, 2023, 1:15 a.m.