现在有图1的数据,要求复原图二的表, class里面的1230对应 I II III other,sex 01 对应 male female,survived 01 对应 number of deaths,population exposed to risk
现在存在的问题是这个复原的表前面两段都已经做出来了,第三段deaths per 100 exposed to risk 做不出来
titanic=read.table("http:",header=FALSE,sep="")
names(titanic)=c("Class","Age","Sex","Survived")
library(foreign)
C=factor(titanic$Class)
table(C)
Sex=factor(titanic$Sex)
table(Sex)
S=factor(titanic$Survived)
table(S)
table(C,Sex,S)
我用的是table(C,Sex,S)把原本的数据分为两个表格,但是由于要做deaths per 100 exposed to risk 的部分,table(C,Sex,S)自身没有办法做除法,到底如何用两个table 把 s= number of Deaths 和population exposed to risk 的情况分开。
说了好大一堆有的没有的,初学R,求大神搭理QAQ
[img]file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\2385052638\QQ\WinTemp\RichOle\J0YQB3)ZBC)%`_D[YM[2M48.png[/img]