r - How to convert a table to a data frame -


i have table in r has str() of this:

 table [1:3, 1:4] 0.166 0.319 0.457 0.261 0.248 ...  - attr(*, "dimnames")=list of 2   ..$ x: chr [1:3] "metro >=1 million" "metro <1 million" "non-metro counties"   ..$ y: chr [1:4] "q1" "q2" "q3" "q4" 

and looks when print it:

                    y x                           q1        q2        q3        q4   metro >=1 million  0.1663567 0.2612212 0.2670441 0.3053781   metro <1 million   0.3192857 0.2480012 0.2341030 0.1986102   non-metro counties 0.4570341 0.2044960 0.2121102 0.1263597 

i want rid of x , y , convert data frame looks same above (three rows, 4 columns), without x or y. if use as.data.frame(mytable), instead this:

                    x  y      freq 1   metro >=1 million q1 0.1663567 2    metro <1 million q1 0.3192857 3  non-metro counties q1 0.4570341 4   metro >=1 million q2 0.2612212 5    metro <1 million q2 0.2480012 6  non-metro counties q2 0.2044960 7   metro >=1 million q3 0.2670441 8    metro <1 million q3 0.2341030 9  non-metro counties q3 0.2121102 10  metro >=1 million q4 0.3053781 11   metro <1 million q4 0.1986102 12 non-metro counties q4 0.1263597 

i fundamentally not understand how tables relate data frames.

i figured out already:

as.data.frame.matrix(mytable)  

does need -- apparently, table needs somehow converted matrix in order appropriately translated data frame. found more details on as.data.frame.matrix() function contingency tables @ computational ecology blog.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -