# Re: [R] Some problems with latex(ftable)

From: Richard M. Heiberger <rmh_at_temple.edu>
Date: Sun 16 Jul 2006 - 07:03:57 EST

Continuing with the example in ?ftable, enter

tmp <- ftable(mtcars$cyl, mtcars$vs, mtcars$am, mtcars$gear, row.vars = c(2, 4),

dnn = c("Cylinders", "V/S", "Transmission", "Gears"))

print.default(tmp)

To get what you are looking for, you will need to intercept write.ftable with, for example,

trace(write.ftable, exit=recover)

then do

3
tmp.latex <- latex(t(x))
print.default(tmp.latex)

Now open up t.latex and prepend
\documentstyle{article}
\begin{document}

and append
\end{document}

then latex it.

This gets you close to what you want and you can work with the generated t.tex file to get the rest of the detail. Or you can work with the numerous arguments we built into latex (see ?latex) to get some of them automatically generated.

tmp2.latex <- latex(t(x), col.just=rep(c("l","r"), c(3,6)),

                    n.rgroup=c(3,6), file="t2.tex")



This works well for one or two examples. To do many, then you will need to follow Frank's suggestion and build all of this into a method. Once the method works well, send it to Frank and he will consider including it in the next release (Frank, I hope that's a fair offer I make for you to do).

print.ftable <- function (x, digits = getOption("digits"), ...) {

     write.ftable(x, quote = FALSE, digits = digits)
invisible(x)


}

Had this been done then the current task would simplify to

latex(write(tmp))

Te question is: why was write.ftable designed to follow the print.ftable constraint on returned value.

ps. I just designed the method. Take write.ftable, drop the last line and give it a new name. then you can latex the output of that new function.

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jul 16 07:19:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 16 Jul 2006 - 16:14:03 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.