public
Description: A R to ascii converter
Homepage: http://eusebe.github.com/ascii
Clone URL: git://github.com/eusebe/ascii.git
ascii /
README.textile

ascii

ascii is an R package that converts common R objects to asciidoc or txt2tags syntax.

It also provides a Sweave driver to embed the R code for complete data analyses in asciidoc or txt2tags documents (see Sweave function and R2HTML package).

example

(see http://eusebe.github.com/ascii)

> library(reshape)
> names(airquality) <- tolower(names(airquality))
> aqm <- melt(airquality, id=c("month", "day"), na.rm=TRUE)
> res <- cast(aqm, month ~ variable, mean, margins="grand_row")
> res
  month    ozone  solar.r      wind     temp
1     5 23.61538 181.2963 11.622581 65.54839
2     6 29.44444 190.1667 10.266667 79.10000
3     7 59.11538 216.4839  8.941935 83.90323
4     8 59.96154 171.8571  8.793548 83.96774
5     9 31.44828 167.4333 10.180000 76.90000
6 (all) 42.12931 185.9315  9.957516 77.88235

> ascii(res, caption = "A great table", footer = T, digits = 3, format = "e", decimal.mark = ",")
.A great table
[options="header,footer"]
|============================================= 
|month|ozone    |solar.r  |wind     |temp     
|5    |2,362e+01|1,813e+02|1,162e+01|6,555e+01
|6    |2,944e+01|1,902e+02|1,027e+01|7,910e+01
|7    |5,912e+01|2,165e+02|8,942e+00|8,390e+01
|8    |5,996e+01|1,719e+02|8,794e+00|8,397e+01
|9    |3,145e+01|1,674e+02|1,018e+01|7,690e+01
|(all)|4,213e+01|1,859e+02|9,958e+00|7,788e+01
|============================================= 
> print(ascii(res, caption = "A great table", footer = T, digits = 3, format = "e", decimal.mark = ","), "t2t")
=====A great table=====
|| month | ozone     | solar.r   | wind      | temp      |
| 5     | 2,362e+01 | 1,813e+02 | 1,162e+01 | 6,555e+01 |
| 6     | 2,944e+01 | 1,902e+02 | 1,027e+01 | 7,910e+01 |
| 7     | 5,912e+01 | 2,165e+02 | 8,942e+00 | 8,390e+01 |
| 8     | 5,996e+01 | 1,719e+02 | 8,794e+00 | 8,397e+01 |
| 9     | 3,145e+01 | 1,674e+02 | 1,018e+01 | 7,690e+01 |
|| (all) | 4,213e+01 | 1,859e+02 | 9,958e+00 | 7,788e+01 |