[R] Is there anywhere recycle()?

From: Gregor Gorjanc <gregor.gorjanc_at_gmail.com>
Date: Mon 24 Jul 2006 - 01:14:25 EST


I am writting a function, which should recycle one of its arguments if length of the argument is approprate i.e. something like

foo <- function(x, a)
  n <- length(x)
  if(length(a) < n) { # recycle a
    oldA <- a
    a <- vector(length=n)
    a[1:n] <- oldA
  ## ...

foo(c(1, 2), a=c(1, 2))
foo(c(1, 2), a=c(1))

I am now wondering if there is any general/generic functions for such task.


Lep pozdrav / With regards,
    Gregor Gorjanc

University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI:
http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888
"One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Mon Jul 24 01:20:50 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 24 Jul 2006 - 02:17:39 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.