Hello R experts,

I trust I have a simple request.  I have a dataframe which among its contents are two variables, qs2 and qs9, which have the following frequencies.

> table(qs2)
qs2
 1  2  3  4 
40 22 11 29 

> table(qs9)
qs9
  1   2   3   4 
162 172  91 179 

I simply want to create a new variable which I have called SchCode that would be filled based on the following logic (written in Systat syntax):

if qs2 = 1 or qs9 = 1 then let SchCode = 1
if qs2 = 2 or qs9 = 2 then let SchCode = 2 
if qs2 = 3 or qs9 = 3 then let SchCode = 3 
if qs2 = 4 or qs9 = 4 then let SchCode = 4

I have looked through my two Ripley texts, searched the R-help, and have tried various ifelse statements, but I cannot get it right.  Help would be appreciated.

Thanks,
Greg Blevins
The Market Solutions Group
	[[alternative HTML version deleted]]


