# Org-babel: Uses

## Table of Contents

`ascii`

Package

`ascii`

package (available on CRAN) creates appropriate plain text
representations of many `R`

objects, and features an option to specify
that the plain text representations should be in Org format (as well
as asciidoc, txt2tags, restructuredtext and textile). This can be
particularly useful for retrieving non-tabular `R`

data structures in
Org.

## Babel Using `ascii`

First, (install), load `ascii`

package and set org as the default
output:

library(ascii) options(asciiType="org")

Le chargement a nÃ©cessitÃ© le package : proto

Then, use `ascii`

function:

ascii(summary(table(1:4, 1:4)))

- Number of cases in table: 4
- Number of factors: 2
- Test for independence of all factors:
- Chisq = 12, df = 9, p-value = 0.2133
- Chi-squared approximation may be incorrect

counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) outcome <- gl(3, 1, 9) treatment <- gl(3, 3) d.AD <- data.frame(treatment, outcome, counts) glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) ascii(glm.D93)

Estimate | Std. Error | z value | Pr(> | z | ) | |
---|---|---|---|---|

(Intercept) | 3.04 | 0.17 | 17.81 | 0.00 |

outcome2 | -0.45 | 0.20 | -2.25 | 0.02 |

outcome3 | -0.29 | 0.19 | -1.52 | 0.13 |

treatment2 | 0.00 | 0.20 | 0.00 | 1.00 |

treatment3 | 0.00 | 0.20 | 0.00 | 1.00 |

ascii(anova(glm.D93))

Df | Deviance | Resid. Df | Resid. Dev | |
---|---|---|---|---|

NULL | 8.00 | 10.58 | ||

outcome | 2.00 | 5.45 | 6.00 | 5.13 |

treatment | 2.00 | 0.00 | 4.00 | 5.13 |

ascii(sessionInfo())

- R version
- R version 2.11.0 (2010-04-22), i486-pc-linux-gnu
- locale
- LC_CTYPE=fr_FR.utf8, LC_NUMERIC=C, LC_TIME=fr_FR.utf8, LC_COLLATE=fr_FR.utf8, LC_MONETARY=C, LC_MESSAGES=fr_FR.utf8, LC_PAPER=fr_FR.utf8, LC_NAME=C, LC_ADDRESS=C, LC_TELEPHONE=C, LC_MEASUREMENT=fr_FR.utf8, LC_IDENTIFICATION=C
- attached base packages
- stats, graphics, grDevices, utils, datasets, methods, base
- other attached packages
- ascii_0.6-3, proto_0.3-8

## With `Sweave`

`ascii`

package provides a `[[http://www.stat.uni-muenchen.de/~leisch/Sweave/][Sweave]]`

driver for org markup.

When using `Sweave`

, just replace `RweaveLatex`

driver by `RweaveOrg`

:

Sweave("yourfile.Rnw", driver = RweaveOrg)

## Bug

### Cell spanning

I am not an Org Mode guru, but as much I can know, Org Mode doesn't
support row or column spanning. The `l/r/t/bgroup`

options of
`ascii`

function are ignored in Org Mode output, and some of these
examples will not produce the expected results.