-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
Of Haoda Fu
Sent: Friday, December 28, 2012 9:43 AM
To: r-help at r-project.org
Cc: haodafu at yahoo.com
Subject: [R] Any simple way to make this happen?
Hi,
The data is
x <- c(4,3,5);
I need to translate it to
y <- c(1,2,3,4,1,2,3,1,2,3,4,5);
i.e. for each number in x, we need to generate 1:x and put it in y.
The program need to evaluate this type of calculation for millions of times in simulation.
Is there any elegant way to make this happen without iteration?
Many thanks!!
Best,
Haoda
[[alternative HTML version deleted]]