Message-ID: <Pine.LNX.4.44.0304020838150.14915-100000@gannet.stats>
Date: 2003-04-02T07:39:05Z
From: Brian Ripley
Subject: vectorize an expression
In-Reply-To: <FFE02AF26875734B82A728403821CB2EFB043A@asp-ri.riverside.csiro.au>
On Wed, 2 Apr 2003 Simon.Gatehouse at csiro.au wrote:
> Dear listers,
> I'm having a bad R day. I just can't think of the vectorized equivalent of:
>
> for (ii in 1:n) aa[ii] = bb[ii,cc[ii]]
aa <- bb[cbind(1:n, cc[1:n])]
--
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595