Problem 1:

data("UCBAdmissions",package="datasets")
View(UCBAdmissions)
## Warning in system2("/usr/bin/otool", c("-L", shQuote(DSO)), stdout = TRUE):
## running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/
## Resources/modules/R_de.so'' had status 1

(a) Find the total number of cases contained in this table

sum(UCBAdmissions)
## [1] 4526

(b) For each department, find the total number of applicants.

margin.table(UCBAdmissions,margin=3)
## Dept
##   A   B   C   D   E   F 
## 933 585 918 792 584 714

(c) For each department, find the overall proportion of applicants who were admitted.

prop.table(margin.table(UCBAdmissions,c(1,3)))
##           Dept
## Admit               A          B          C          D          E
##   Admitted 0.13278833 0.08174989 0.07114450 0.05943438 0.03247901
##   Rejected 0.07335395 0.04750331 0.13168361 0.11555457 0.09655325
##           Dept
## Admit               F
##   Admitted 0.01016350
##   Rejected 0.14759169

(d) Construct a tabular display of department (rows) and gender (columns), showing the proportion of applicants in each cell who were admitted relative to the total applicants in that cell.

ftable(prop.table(UCBAdmissions,c(2,3)),2)
##                 Dept          A          B          C          D          E          F
## Admit    Gender                                                                       
## Admitted Male        0.62060606 0.63035714 0.36923077 0.33093525 0.27748691 0.05898123
##          Female      0.82407407 0.68000000 0.34064081 0.34933333 0.23918575 0.07038123
## Rejected Male        0.37939394 0.36964286 0.63076923 0.66906475 0.72251309 0.94101877
##          Female      0.17592593 0.32000000 0.65935919 0.65066667 0.76081425 0.92961877

Problem 2:

data("UKSoccer",package="vcd")
ftable(UKSoccer)
##      Away  0  1  2  3  4
## Home                    
## 0         27 29 10  8  2
## 1         59 53 14 12  4
## 2         28 32 14 12  4
## 3         19 14  7  4  1
## 4          7  8 10  2  0

(a) Verify that the total number of games represented in this table is 380.

sum(UKSoccer)
## [1] 380

(b)Find the marginal total of the number of goals scored by each of the home and away teams.

addmargins(UKSoccer)
##      Away
## Home    0   1   2   3   4 Sum
##   0    27  29  10   8   2  76
##   1    59  53  14  12   4 142
##   2    28  32  14  12   4  90
##   3    19  14   7   4   1  45
##   4     7   8  10   2   0  27
##   Sum 140 136  55  38  11 380

(c) Express each of the marginal totals as proportions.

prop.table(addmargins(UKSoccer))
##      Away
## Home             0            1            2            3            4
##   0   0.0177631579 0.0190789474 0.0065789474 0.0052631579 0.0013157895
##   1   0.0388157895 0.0348684211 0.0092105263 0.0078947368 0.0026315789
##   2   0.0184210526 0.0210526316 0.0092105263 0.0078947368 0.0026315789
##   3   0.0125000000 0.0092105263 0.0046052632 0.0026315789 0.0006578947
##   4   0.0046052632 0.0052631579 0.0065789474 0.0013157895 0.0000000000
##   Sum 0.0921052632 0.0894736842 0.0361842105 0.0250000000 0.0072368421
##      Away
## Home           Sum
##   0   0.0500000000
##   1   0.0934210526
##   2   0.0592105263
##   3   0.0296052632
##   4   0.0177631579
##   Sum 0.2500000000