Skip to content
Prev 334101 / 398513 Next

Need help figuring out sapply (and similar functions) with multiple parameter user defined function

Thank you for your response!

I am attempting to determine a preference from the answers to three 
binomial questions;

q.1) 1 or 2    q.2) 1 or 3    q.3) 2 or 3

However, the questions are coded with either a 1 or 2 (though no answer 
is also possible) and the first three functions (q#.ans) convert those 
values to the 1,2,or 3 shown above

and generate one of the following result for each row of the table; 0 - 
no preference, or 1,2,3 which indicates the preference indicated by the 
question

The if's implement the following state conditions:

   # ID A  B  C  Preference
   # 1  0  0  0  None
   # 2  0  0  1  None
   # 3  0  0  2  None
   # 4  0  1  0  None
   # 5  0  1  1  Option 1
   # 6  0  1  2  None
   # 7  0  2  0  None
   # 8  0  2  1  None
   # 9  0  2  2  Option 2
   # 10 1  0  0  None
   # 11 1  0  1  Option 1
   # 12 1  0  2  None
   # 13 1  1  0  Option 1
   # 14 1  1  1  Option 1
   # 15 1  1  2  Option 1
   # 16 1  2  0  None
   # 17 1  2  1  Option 1
   # 18 1  2  2  Option 2
   # 19 2  0  0  None
   # 20 2  0  1  None
   # 21 2  0  2  Option 2
   # 22 2  1  0  None
   # 23 2  1  1  Option 1
   # 24 2  1  2  Option 2
   # 25 2  2  0  Option 2
   # 26 2  2  1  Option 2
   # 27 2  2  2  Option 2

The if statement only implements those values from the state machine 
that show a preference (ID's 5,9,11,13-15,17-18,21,23-27)
On 12/06/2013 09:59 AM, PIKAL Petr wrote: