Re: [R] How do I make a Sweave + latex table out of this ?

From: David Whiting <david.whiting_at_ncl.ac.uk>
Date: Fri 19 Aug 2005 - 04:39:40 EST

Hi Fredrik,

You can do this nicely with latex() if you massage this a little so that you end up with a data frame that includes a column for agemF (to indicate which agemF each row belongs to) and then use the rgroup and n.rgroup options of latex().

Dave

Fredrik Karlsson wrote:
> Dear list,
>
> I have a table that I would like to convert to latex for inclusion
> into a Sweave file.
>
>
>

>>round(ftable(prop.table(xtabs(~agemF + votcat + Type , data=work),margin=2))*100,1)

>
> Type Voiced Voiceless unaspirated Voiceless aspirated
> agemF votcat
> 18 - 24 Prevoiced 2.6 8.7 2.3
> Short lag 5.8 6.7 5.1
> Long lag 1.0 1.9 2.9
> 24 - 30 Prevoiced 15.1 10.5 1.7
> Short lag 9.2 15.3 5.8
> Long lag 3.5 8.1 15.8
> 30 - 36 Prevoiced 12.8 14.0 2.6
> Short lag 10.2 14.2 3.0
> Long lag 2.3 5.5 22.2
> 36 - 42 Prevoiced 4.4 6.4 0.6
> Short lag 4.0 5.9 1.5
> Long lag 1.3 2.9 9.4
> 42 - 48 Prevoiced 6.4 2.3 0.3
> Short lag 3.0 2.8 1.4
> Long lag 0.6 7.7 8.8
> 48 - 54 Prevoiced 4.9 4.1 0.3
> Short lag 2.0 2.7 1.3
> Long lag 0.3 0.9 4.7
>
>
> However, I have not been able to use this as a table. The Hmisc latex
> command only accepts the input if I first convert it to a data.frame
> format, and that makes the output much more difficult to read as it
> duplicates the category levels of agemF.
>
> Is there a way to do this?
>
>
> /Fredrik Karlsson
>
> ______________________________________________
> 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
>
-- 
David Whiting
School of Clinical Medical Sciences, The Medical School
University of Newcastle upon Tyne, NE2 4HH, UK.

"I love deadlines. I love the whooshing noise they make as they go by"
(Douglas Adams)

______________________________________________
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 Fri Aug 19 04:47:36 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:31:30 EST