[R] Creating a sequence of variables in a data frame

Jason Turner jasont at indigoindustrial.co.nz
Mon Mar 10 10:04:25 CET 2003


On Mon, Mar 10, 2003 at 08:14:54AM +0000, ripley at stats.ox.ac.uk wrote:
> On Mon, 10 Mar 2003, Jason Turner wrote:
> > for(jj in 1:5) { 
> >   foo[[jj + 1]] [which(foo$old == jj)] <- TRUE #note - same offset
> >                                                #from above
> > }
> 
> You don't need the which(), as logical indices are just as good.

(sound of forehead slapping).  Somebody spiked my coffee with decaf.

> library(nnet)
> ?class.ind

Nice.

Many thanks, for the pointer above, and for nnet.  Both are very much
appreciated.

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz



More information about the R-help mailing list