From: Richard M. Heiberger <rmh_at_temple.edu>

Date: Sun 16 Jul 2006 - 07:03:57 EST

}

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

Date: Sun 16 Jul 2006 - 07:03:57 EST

The ftable structure is not an ordinary matrix. Instead, it has the
body of the table with several cbind- and rbind-ed rows and columns of
label information. The example in ?ftable has two row factors and two
column factors.

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"))

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

trace(write.ftable, exit=recover)

3

tmp.latex <- latex(t(x))

print.default(tmp.latex)

Now open up t.latex and prepend

\documentstyle{article}

\begin{document}

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

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

Now open up t2.latex and pre- and append the latex controls to it.

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).

This raises a question from me to the R developers. I would have written write.ftable to return t(x), not ox. print is constrained to return its argument. I thought write had more freedom. Then I would respecify

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.
*