Skip to content
Prev 334107 / 398513 Next

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

On 12/06/2013 10:43 AM, William Dunlap wrote:
I misunderstood.  I thought it was apply the func to each row...  My mistake
I will need to think about this, I am not sure I understand.  I really 
don't seem to understand how any of the apply functions seem to work.
I already have tested my functions by using a for loop, and they work.  
Here is the for loop I use.

for (indx in 1:length(df$ID)) {
     df$Preference <- 
evaluate.questions(df$Q1[indx],df$Q2[indx],df$Q3[indx])
}

I understand that such for loops aren't 'best practice' in R and am 
trying to learn its approach.  Thank you for the suggestions!