Skip to content
Prev 320452 / 398506 Next

Passing arguments between apply and l(s)apply functions vs. nested for loop

Mark Orr <mo2259 <at> columbia.edu> writes:
[snip]
Given the constraint you state about uniqueness,
1 2 3 
1 2 2 

gives the same answer as catch.all --- up to names which you can 
remove with unname(table(factor(unlist(l),v)))


[deleted]
earlier problems?


Always helps to ponder the error message --- 'recursive default argument'.

Here is an example:

foo <- function(x=x) x
Error in foo() : 
  promise already under evaluation: recursive default argument reference 
  or earlier problems?
[1] 1
The default is what you use when the argument is not given in the call.

And x=x confuses the evaluator. 

You can avoid confusion by choosing a different name like this:
[1] 3
[rest deleted]

HTH,