Re: [R] Help with creating conditional categorical variables in R

2012-04-18 Thread R. Michael Weylandt
Your problem is that columns A & B contain something that can't be ordered. (Likely "factor" (=categorical) data like Male / Female rather than numeric like 10 and 5) Use str(data_2) to see what classes your data are -- they sometimes get converted in unexpected ways if you aren't careful in setti

[R] Help with creating conditional categorical variables in R

2012-04-18 Thread Dwaipayan Dasgupta
Hi, I am stuck with creating a conditional categorical variable in R If my dataframe data_2 has 3 variables A,B,CI want to create variable D which would be something like : data_2$D <- ifelse(data_2$A < data_2$B & promotion_ind =="N",1,0), this throws up an error "In Ops.factor(data_2$A,dat