[R] exporting ftable

Henrique Dallazuanna
Wed, 02 Jul 2008 20:01:01 -0000

See ?write.ftable

On Wed, Jul 2, 2008 at 4:56 PM, Leandro Marino <leandro@cesgranrio.org.br>
wrote:

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



--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]