[R] Maximum recursion depth and unique()

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Dec 31 08:23:29 CET 2001

On Sun, 30 Dec 2001, Mark E. Fenner wrote:

> Two questions:
> First, what is R's maximum recursion depth (for function evaluations)?  Is
> the value stored in a variable?  Can the value be modified?

?options says

expressions: sets a limit on the number of nested expressions that will
          be evaluated.  This is especially important on the Macintosh
          since stack overflow is likely if this is set too high. Valid
          values are 25...100000 with default 500.

It is unlikely that you need to increase it if you are using R
efficiently, though.

> Second, I've hacked out a function to take a matrix (array) of data and
> return another that is the same except it removes any duplicate
> columns.  After doing this I discovered the unique() function and I tried
> to use it via apply() to do the same thing my function
> "removeduplicates" did.
> The closest I came to something that worked was "apply(t, 1, unique)" and
> taking the transpose of this result (t is an 2D array).  This
> didn't make sense at first; then I realized that the duplication I
> was looking for was a "row by row" duplication.  I don't
> think what I have there will work in the general case.  So, does anyone
> know how to use "unique" to remove duplicate columns from a 2D data
> object?

See unique.data.frame (new in 1.4.0)

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list