[R] exporting ftable

From: Leandro Marino <leandro_at_cesgranrio.org.br>
Date: Wed, 02 Jul 2008 16:56:52 -0300

   How can I export an ftable object in the same format that appears in R command window?
For testing that i was using this example that is in help of this function.

## Start with a contingency table.

ftable(Titanic, row.vars = 1:3)
ftable(Titanic, row.vars = 1:2, col.vars = "Survived")
ftable(Titanic, row.vars = 2:1, col.vars = "Survived")

## Start with a data frame.
x <- ftable(mtcars[c("cyl", "vs", "am", "gear")]) x
ftable(x, row.vars = c(2, 4))

## Start with expressions, use table()'s "dnn" to change labels ftable(mtcars$cyl, mtcars$vs, mtcars$am, mtcars$gear, row.vars = c(2, 4),

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

When I tried to export the object x i have thsis result:
"V1" "V2" "V3"
"1" 0 0 0
"2" 0 0 1
"3" 1 2 0
"4" 0 6 1
"5" 0 0 0
"6" 0 2 1
"7" 2 2 0
"8" 0 0 0
"9" 12 0 0
"10" 0 0 2
"11" 0 0 0
"12" 0 0 0

I used to export: write.table(x,"c:/x.txt")

Thanks in advance!

Best regards,

Atenciosamente,
Leandro Lins Marino
Centro de Avaliação
Fundação CESGRANRIO
Rua Santa Alexandrina, 1011 - 2º andar
Rio de Janeiro, RJ - CEP: 20261-903
( (21) 2103-9600 R.:236
( (21) 8777-7907
* leandro_at_cesgranrio.org.br
"Aquele que suporta o peso da sociedade

    é precisamente aquele que obtém
 as menores vantagens". (SMITH, Adam)

P Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jul 2008 - 19:58:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 20:31:51 GMT.

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

list of date sections of archive