Arguments to a call-- was [R] finding the most frequent row

Berton Gunter gunter.berton at gene.com
Fri Dec 10 17:32:03 CET 2004


> Here's something that works. I'm sure there are better solutions (in
> particular the paste part - I couldn't figure out how to avoid typing
> a[i,1], ..., a[i,10]).

This is a language issue that arises frequently. One standard approach is to
use do.call() as in:

... result <- do.call("paste",as.data.frame(yourmatrix), sep="")

The bit to notice here is that the "args" argument to do.call must be a
list, which is why the conversion to a data.frame (which IS a list) is used.

V&R's S PROGRAMMING book discusses this and many related issues in their
"Computing on the Language" chapter. I find it challenging, but invaluable.


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box




More information about the R-help mailing list