Skip to content
Prev 313571 / 398502 Next

Repeat elements of matrix based on vector counts

Hi Sarah,

If I understand your requirements correctly, the easiest thing to do
is approach it from a different direction:
df3a <- merge(df1, df2)

But you can also use rep for this simple example because plot.id in
df2 is sorted:
nindex <- table(df1$plot.id)
df3b <- df2[rep(1:length(nindex), times=nindex),]

Thanks for the reproducible example,
Sarah
On Thu, Dec 13, 2012 at 9:15 AM, Sarah Haas <haaszoology at gmail.com> wrote:
--
Sarah Goslee
http://www.functionaldiversity.org