Skip to content

Converting an ftable (contingency table) to a dataframe in R

2 messages · Mark Alen, Richard M. Heiberger

#
I am generating an ftable (by running ftable on the results of a xtabs command) and I am getting the following.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Var1? Var2
date ? ? ? ? ? ? ? ? group? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
2007-01-01? ? ? ? ? q1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1? ? 9
? ? ? ? ? ? ? ? ? ? ?q2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?2? ? 8
? ? ? ? ? ? ? ? ? ? ?q3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?3? ? 7
2007-01-02? ? ? ? ? q1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?6? ? 6
? ? ? ? ? ? ? ? ? ? ?q2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?7? ? 5
? ? ? ? ? ? ? ? ? ? ?q3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?8? ? 4

I understand that it is a ftable class but I'd like to store is as the following. I am wondering if there is any efficient way of doing it in R?
date ? ? ? ? ? ? ? ? group? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Var1? Var2? ? ? ? ?
2007-01-01? ? ? ? ? q1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1? ? 9
2007-01-01? ? ? ? ? q2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?2? ? 8
2007-01-01? ? ? ? ? q3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?3? ? 7
2007-01-02? ? ? ? ? q1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?6? ? 6
2007-01-02? ? ? ? ? q2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?7? ? 5
2007-01-02? ? ? ? ? q3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?8? ? 4



I don't know how this email will look in the mailing list so I have also asked it here 
http://stackoverflow.com/questions/6462769/converting-an-ftable-contingency-table-to-a-dataframe-in-r