# R-Code for March 31st. #See MArch 29th R Code for an legend and explanation of the below data. We know have 4 new categories. #Legned #F=Female passengers #M=Male passengers #A=Alive, i.e. survivors #D=Dead, i.e.victims #1=First class passengers #2=Second class passengers #3=Third class passengers #C=Crew # AF=Female and Survivor # AD=Female and Victim # AF=Male and Survivor # AF=Male and Victim # Rows AF,AM,DF,DM # Columns 1,2,3, C A=rbind( c(98,57,85,26), c(104,61,93,186), c(63,84,270,83), c(60,83,258,590)) M1=margin.table(A,1) F1=diag(1/M1)%*%A M2=margin.table(A,2) F2=A%*%diag(1/M2) ################### # Goal: Find the percentage of female survivors in each class. #The female survivors are: A[1,] #First notice the Females in each class are: A[1,]+A[3,] # Hence, the percentage of female survivors in each class (Call them PF) are: PF=A[1,]/(A[1,]+A[3,]) # Exercise: the percentage of male survivors in each class (Call them PF) are? #Answer: PM=A[2,]/(A[2,]+A[4,]) # We can compare the percentage of female survivors in each class. pie(PF,labels=c("First","Second","Third","Crew"),main="Percentage of female survivors in each class") # With the percentage of female survivors in each class quartz() pie(PM,labels=c("First","Second","Third","Crew"),main="Percentage of male survivors in each class") # Question 1: Compare PM and PF with the percentage of female verse male survivors (over all), what happened? # Question 2: Are these really "pie charts"? Why or why not? # Question 3: Do our "pie charts" indicate that something is independent of something else? If so, then what things are independent and how is this indicated?