Skip to content
This repository

An R package for generating markup tables

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 R
Octocat-spinner-32 inst
Octocat-spinner-32 vignettes
Octocat-spinner-32 .gitignore
Octocat-spinner-32 DESCRIPTION
Octocat-spinner-32 NAMESPACE
Octocat-spinner-32 README.org
README.org

mutable

The mutable package provides a flexible method for generating markup tables from the R programming language. It allows users to construct objects representing arbitrary tabular material and output the object into a variety of formats. LaTeX, HTML, and plain text output functions are included by default.

Users can supply their own formatting functions for these output types, and easily create their own. For example, the provided LaTeX output style for factors (percentage and fraction) can be completely changed if the user specifies their own muExportLatex function. The modular design of the package allows every markup decision to be overridden easily and consistently. The result is that the user is in complete control over the final markup produced, and that multiple versions of the same table can easily be produced from the same data simultaneously.

Installation

require(devtools)
require(Hmisc)
install_github("mutable", "erikriverson")

Examples

Load sample data

data(airquality)

Give unlabeled variables appropriate labels

label(airquality$Ozone)   <- 'Ozone (ppb)'
label(airquality$Solar.R) <- 'Solar R (lang)'
label(airquality$Wind)    <- 'Wind (mph)'
label(airquality$Temp)    <- 'Temperature (degrees F)'
airquality$Month <- factor(airquality$Month,
                           labels = month.abb[5:9])

:

Use the mutable formula interface to create a complete table, by default in plain text, LaTeX, and HTML formats

library(mutable)
m1 <- mutable(Month ~ Ozone + Solar.R + Wind + Temp, data = airquality)

Print the table in the running R session

m1 

Print out HTML and LaTeX version of the table using default export functions. Note all rows/columns/cells are uniquely identified for CSS customization.

html(m1)
latex(m1)

The table contains the following information.

Variable N May Jun Jul Aug Sep Overall
Ozone (ppb) 116 23.62/22.22 29.44/18.21 59.12/31.64 59.96/39.68 31.45/24.14 42.13/32.99
Solar R (lang) 146 181.3/115.08 190.17/92.88 216.48/80.57 171.86/76.83 167.43/79.12 185.93/90.06
Wind (mph) 153 11.62/3.53 10.27/3.77 8.94/3.04 8.79/3.23 10.18/3.46 9.96/3.52
Temperature (degrees F) 153 65.55/6.85 79.1/6.6 83.9/4.32 83.97/6.59 76.9/8.36 77.88/9.47
Something went wrong with that request. Please try again.