Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 1.4 KB

Textile-test-1.nw

File metadata and controls

68 lines (53 loc) · 1.4 KB

A Test File

Friedrich Leisch (adapted by Mark Clements)

We load the ascii package and set the output type as "textile".

<<echo=TRUE,print=FALSE>>=
library(ascii)
options(asciiType=“textile”)
@

A simple example: the integers from 1 to 10 are
<<print=TRUE,results=ascii>>=
ascii(1:10)
@
<<echo=FALSE,results=hide>>=
print(1:20)
@

We can also emulate a simple calculator:
<<echo=TRUE,print=TRUE>>=
1 + 1
1 + pi
sin(pi/2)
@

Now we look at Gaussian data:

<<results=ascii>>=
library(stats)
set.seed(12345)
ascii(x <- rnorm(20))
ascii(t1 <- t.test(x))
@

Note that we can easily integrate some numbers into standard text: The
third element of vector x is \Sexpr{x3}, the
p-value of the test is \Sexpr{format.pval(t1$p.value)}.

Now we look at a summary of the famous iris data set, and we
want to see the commands in the code chunks:

<<results=ascii>>=
data(iris)
ascii(summary(iris))
@

<<fig=TRUE,results=ascii>>=
library(graphics)
pairs(iris)
@
Pairs plot of the iris data

<<fig=true,results=ascii>>=
boxplot(Sepal.Length~Species, data=iris)
@
Boxplot of sepal length grouped by species.

Finally, we test the new asciiCoefmat function:

<<results=ascii>>=
library(stats)
x = y = 1:10
y1 = 5
lm(y ~ x) |> summary() |> coef() |> asciiCoefmat()
@