From p.dalgaard at biostat.ku.dk  Sat Jul  5 14:04:33 2008
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Sat, 05 Jul 2008 14:04:33 +0200
Subject: [Rd] [[ vs. .subset2
In-Reply-To: <971536df0807041813m63e712d7q14e5e28979d0cc16@mail.gmail.com>
References: <971536df0807041712x34dafd51xc2ad8dcf0ef30b68@mail.gmail.com>	<486EC37B.9020204@pdf.com>
	<971536df0807041813m63e712d7q14e5e28979d0cc16@mail.gmail.com>
Message-ID: <486F6351.8070601@biostat.ku.dk>

Gabor Grothendieck wrote:
> Not really.  The point of this is that promises seem to be
> screwing up in conjunction with [[ but in light of the fact
> that .subset2 works it suggests that there might be a better
> implementation of [[
Not really; .subset2() is a shortcut that bypasses method dispatch, so 
not a drop-in replacement for "[[". You also have

 > test3 <- function(pf = parent.frame()) "[[.data.frame"(BOD, pf$idx)
 > test3()
[1]  8.3 10.3 19.0 16.0 15.6 19.8


Something appears not quite right, but an easy workaround is to force 
the promise:

 > test4 <- function(pf = parent.frame()) {pf;BOD[[pf$idx]]}
 > test4()
[1]  8.3 10.3 19.0 16.0 15.6 19.8



-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



[Rd] [[ vs. .subset2
Peter Dalgaard