statistics - Three factor contingency table in R -
I'm looking to build contingency table for three main effects. The crime, gender, and former beliefs are the response variables whether a generous sentence was provided or not.
This is by far the best.
crime gender old yes no 1 shopping male n 24 1 2 other theft act men n 52 9 3 shoplifting women n 48 3 4 other theft act women n 22 2 5 shop lift men p 17 6 6 Other Theft Act Mens P 60 34 7 Shop Lifting Women P15 6 8 Other Theft Act Women P4 3
which was created by the following code
Table1 & lt; -expand.grid (crime = factor (c ("Shoplifting", "Other theft Act"), gender = factor (C ("male", "woman")), pryarkov = factor (c ("n", "p "))) Table 1 & lt; -data.frame (Table 1, Yes = C (24, 52,48,22,17,60,15,4), No = C (1,9,3,2, 6,34,6,3))
Unfortunately this is not very beautiful and therefore I was thinking that there is another way to present the data more clearly.
Thank you.
For contingency, you sample operator use And the number of strings such as
factory <---> gender> gender> (sample (c ("male", "woman"), i, replaced = (sample (C) ("Shoplifting", "Other Theft Act"), I, Table) - Factory () () () () () () () 20)
Result:
crime gender preconv 1 shopping male en 2 shopping lady female p 3 other theft act men p4 shopping men's p5 other theft act women n 6 shoplifting woman n7 shoplifting Shake P8 Shop Lifting Male P 9 Other Theft Act Women P10 Shop Lifting Male P 11 Other Theft Act Mens N12 Other Theft Act Men's P13 Shop Lifting Men P14 Shoplifting NN 15 Other Theft Act Mens N 16 Other Theft Act Mens P 17 Other Theft Act Women P18 Shop Lifting Women P1 Other Theft Act Mens N20 Shop Lifting Women N
Comments
Post a Comment