I have a data frame that I read from a file: sassign. I created a frequency table using prop.table(). Here's what I used:
prop.table(table(sassign$state))
Output is:
AE CT DC DE MA MD ME NH NJ NY PA RI VA VI VT
0.00010 0.05024 0.00678 0.01422 0.08504 0.08344 0.00686 0.01330 0.22136 0.33060 0.17436 0.00804 0.00054 0.00090 0.00422
This output is very clunky. Is there any way I can organize this as a column, include number of occurences and then sort it?
I also tried CrossTabs, but it's even more clunkier.
CrossTable(sassign$state)
Cell Contents
|-------------------------|
| N |
| N / Table Total |
|-------------------------|
Total Observations in Table: 50000
| AE | CT | DC | DE | MA |
|-----------|-----------|-----------|-----------|-----------|
| 5 | 2512 | 339 | 711 | 4252 |
| 0.000 | 0.050 | 0.007 | 0.014 | 0.085 |
|-----------|-----------|-----------|-----------|-----------|
| MD | ME | NH | NJ | NY |
|-----------|-----------|-----------|-----------|-----------|
| 4172 | 343 | 665 | 11068 | 16530 |
| 0.083 | 0.007 | 0.013 | 0.221 | 0.331 |
|-----------|-----------|-----------|-----------|-----------|
| PA | RI | VA | VI | VT |
|-----------|-----------|-----------|-----------|-----------|
| 8718 | 402 | 27 | 45 | 211 |
| 0.174 | 0.008 | 0.001 | 0.001 | 0.004 |
|-----------|-----------|-----------|-----------|-----------|
I'm a beginner and have started working with R for past 4 days. I've spent about 4 hours on this situation, so I'd appreciate any help. Thanks in advance.