How to get the proportion in table command of R?

r
kaggle

#1

I am currently trying to solve kaggle titanic problem I want to see how Sex variable effects the survival of the passenger for this I have used the table function but I want to know proportion by which Sex affects the Survival.

table(train$Sex, train$Survived)
        
           0   1
  female  81 233
  male   468 109

Here the numbers are absolute.I want them in proportion.


#2

prop.table(table(train$Sex, train$Survived))

              0          1

female 0.09090909 0.26150393
male 0.52525253 0.12233446

if you want row wise proportion:

prop.table(table(train$Sex, train$Survived), 1)

             0         1

female 0.2579618 0.7420382
male 0.8110919 0.1889081

for column-wise proportion:

prop.table(table(train$Sex, train$Survived), 2)

             0         1

female 0.1475410 0.6812865
male 0.8524590 0.3187135