> x <- c(1, 2, 3)
> n <- 10
> ## so using the recycling rules, I would like to get from FUN(x, n)==1
> ## I am doing:
> xRecycled <- rep(x, length.out=n)[n]
> 
> This works, but it seems to me that I am missing something really basic 
here
> - is there  more straightforward way of doing this?

x[n %% length(x)] gives you the same answer as rep(x, length.out=n)[n], 
without having to create the longer vector.

Regards,
Richie.

Mathematical Sciences Unit
HSL
4D Pie Charts



------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:22}}

______________________________________________
R-help@r-project.org 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.

Reply via email to