[R] Fwd: Categorial Response Questions
andyer weng
nzandyer at gmail.com
Sat Oct 18 07:40:19 CEST 2008
hi all,
me again. i try to type the following coding for my question below,
but it comes up a error messgae. please advise whether the way i was
trying to do will solve my question stated in the previous email. If
so , please advise what is wrong with my coding.
(p.s. all the data are stored in xxx.df)
> grouped.xxx.df<-data.frame(group.age.group=sort(unique(xxx.df$age.group)),
+ expand.grid(sex=c("female","male"),age.group=c("0-9","10-19","20-29","30-39","40-49","50-59","60-69","70-79")),
+ r=tapply(xxx.df$survived,titanic.df$age.group,sum),
+ n=tapply(xxx.df$survived,titanic.df$age.group,length))
Error in data.frame(group.age.group = sort(unique(xxx.df$age.group)), :
arguments imply differing number of rows: 8, 16
In addition: Warning messages:
1: In Ops.factor(left) : + not meaningful for factors
2: In Ops.factor(left) : + not meaningful for factors
thanks millions.
Regards,
Andyer
---------- Forwarded message ----------
From: andyer weng <nzandyer at gmail.com>
Date: 2008/10/18
Subject: Fwd: Categorial Response Questions
To: r-help at r-project.org
Sorry Guys, i press the wrong button to send out the uncompleted message.
let me do it again.
my purpose for below questions is to assess the effect of class, age
and sex on the survival.
I have a data set containing :
pclass: A factor giving the class of the passenger: one of 1st, 2nd, 3rd.
age: The age of the passenger in years.
sex: Passenger's gender: female or male
age.group: Passengers age group, one of 0‐9 , 10‐19, 20‐29,
30‐39, 40‐49, 50‐59, 60‐69,70‐79
survived: Passenger's survival (1=survived, 0=did not survive)
Ignoring the variable age,
- I need to group the data into groups corresponding to each
age‐group/sex/class combination,
- I need to compute the logits for each combination.
- Make a data frame containing the logits, and the categorical
variables. I need to have one line in the data frame for each
combination of the factor levels.
Can someone please help with the R code for above???!!!
Thanks millions!!
Cheers
Andyer.
More information about the R-help
mailing list