[R] latex

Patrick Hausmann patrick.hausmann at uni-bremen.de
Wed Jul 3 19:51:59 CEST 2002

Hi Christian,

unfortunalty I can't help you with your problem (but I see 
Mr. Harrell has send an answer). 
Maybe you are interested in another solution how 
to combine Latex and R (using "Sweave"[1]).

1. You need the library "tools" from CRAN
2. Save the next lines as 'c:\beispiel.rnw'

% ---- beispiel.rnw ----------


% ------ R-Code - Berechnung XYZ -------
a <- c(3,4,5,6,7,6,5,4,3,6)
b <- c(6,5,4,5,6,7,8,6,5,5)
mean.a <- mean(a)
da <- density(a)
db <- density(b)
% ------ R-Code - Berechnung XYZ -------

The mean of a is \Sexpr{mean.a}.

The kernel density from a and b:

plot(da, xlim=range(da$x, db$x), ylim=range(da$y,
lines(db, col="red")

summary.stats <-  cbind(
'Mean (b)'=mean(b),
'SD (a)'=sd(a))
latex(summary.stats, fi='table.tex')

% ---- beispiel.rnw ----------

3. Start R 
4. R> library(tools)
5. R> Sweave("C:/beispiel.rnw")
6. Now you can "latexen" the file 'beispiel.tex' 

Regards Patrick

[1] See:

[2] There is a new LaTeX-package called 'ctable'. 
Purpose: "The 'ctable' package lets you easily typeset centered, captioned table and 
figures floats with optional footnotes [...]." Maybe you take a look.

Patrick Hausmann
Friedrich-Wilhelm Str. 37 - D-28199 Bremen
Tel. +49 421 5980631 - Fax. +49 421 5980632
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list