[R] Behavior of [[ in S vs. R

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Oct 18 13:53:53 CEST 2003


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> which suggests that the R difference is unintentional.

It was. While inserting the unclass-eliminating code, I seem to have
switched ..1 and ..2 around:

-- src/library/base/R/dataframe.R      25 Mar 2002 17:48:30 -0000   1.51
+++ src/library/base/R/dataframe.R      5 May 2002 22:34:53 -0000   1.52
@@ -404,11 +404,11 @@
     ## explicitly. Also will check for wrong number or empty args
     if(nargs() < 3)
        (function(x, i)
-        if(is.matrix(i))
-        as.matrix(x)[[i]]
-        else unclass(x)[[i]])(x, ...)
-    else (function(x, i, j)
-         x[[j]][[i]])(unclass(x), ...)
+         if(is.matrix(i))
+         as.matrix(x)[[i]]
+         else .subset2(x,i))(x, ...)
+    else
+        .subset2(.subset2(x,..1),..2)
 }


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list