>>>>> "Vladimir" == Vladimir Dergachev <[EMAIL PROTECTED]>
>>>>>     on Wed, 13 Dec 2006 13:03:21 -0500 writes:

    Vladimir> On Wednesday 13 December 2006 6:01 am, Martin Maechler wrote:
    >> 
    >> - Vladimir, have you verified your 'take2' against recent versions
    >> of R-devel?

    Vladimir> Yes. 

indeed it applies cleanly

    >> - If they still work, could you re-post them to R-devel, this
    >> time using a proper MIME type,
    >> i.e. most probably one of
    >> application/x-tar
    >> application/x-compressed-tar
    >> application/x-gzip
    >> 
    >> In case you don't know how to achieve this,
    >> I'd be interested to get it by "private" e-mail.

    Vladimir> No problem. The old e-mail did have a mime type: "text/x-diff".
    Vladimir> I am resending the patch - now compressed, hopefully it will get 
pass whatever 
    Vladimir> filters are in place.

It did pass --- and  "text/x-diff" should pass through too from
now on.

However, even though the patch looks quite ok
{apart from one border case:  swiss[2, , drop = TRUE]  should give a list;
 and that was easy to fix; see the attached dataframe.R-diff
 file which incorporates that fix (and my other cosmetic changes)}

but running 'make check-all' then shows segmentation faults --- only on one 
platform of the
two I've tested {in mgcv's gam() example, boot's  boot()
                 example, and I think one other place}
My guess: typically when dealing with model.frames (which
   internally are "just" data frames with a particular "terms" attribute)
but the problems are not reproducible when run interactively.
It may really be that .subset() and .subset2() are sometimes
used in cases they should not be in your new code; or they even have a bug that
is not triggered unless by using them in the new context of [.data.frame

So I'm sorry, but we might have to wait for a "take 3"
or rather try to find the problem with your patch. 
Maybe you can try yourself?

--- dataframe.R.prev	2006-12-16 18:39:05.000141000 +0100
+++ dataframe.R		2006-12-16 21:03:24.000028000 +0100
@@ -143,7 +143,7 @@
                         stringsAsFactors = stringsAsFactors)))
     if(any(m > 0)) names(x) <- sub("^\\.\\.adfl\\.", "", names(x))
     if(!is.null(row.names)) {
-	# row.names <- as.character(row.names)
+	## row.names <- as.character(row.names)
 	if(length(row.names) != dim(x)[[1]])
             stop(gettextf("supplied %d row names for %d rows",
                           length(row.names), dim(x)[[1]]), domain = NA)
@@ -472,12 +472,13 @@
     rows <- attr(x, "row.names")
     cols <- names(x)
     cl <- oldClass(x) # doesn't really matter unless called directly
-    class(x) <- attr(x, "row.names") <- NULL
 
+    ## The references to x[] below should all use .subset or .subset2,
+    ## as opposed to modifying class and attributes (as in R < 2.5.0).
 
     if(missing(i)) { # df[, j] or df[ , ]
         ## handle the column only subsetting ...
-        if(!missing(j)) x <- x[j]
+        if(!missing(j)) x <- .subset(x, j)
 	cols <- names(x)
 	if(any(is.na(cols))) stop("undefined columns selected")
     }
@@ -486,14 +487,15 @@
 	    i <- pmatch(i, as.character(rows), duplicates.ok = TRUE)
 	rows <- rows[i]
 	if(!missing(j)) { # df[i, j]
-	    x <- x[j]
+	    x <- .subset(x, j)
 	    cols <- names(x)
 	    if(any(is.na(cols))) stop("undefined columns selected")
 	}
 	for(j in seq_along(x)) {
-	    xj <- x[[j]]
+	    xj <- .subset2(x, j)
             ## had drop = drop prior to 1.8.0
-	    x[[j]] <- if(length(dim(xj)) != 2) xj[i] else xj[i, , drop = FALSE]
+	    x <- .subassign2(x, j, ## " x[[j]] <- "
+			     if(length(dim(xj)) != 2) xj[i] else xj[i, , drop = FALSE])
 	}
     }
     if(drop) {
@@ -503,14 +505,14 @@
 	    drop <- TRUE
 	}
 	else if(n > 1) {
-	    xj <- x[[1]]
+	    xj <- .subset2(x, 1)
 	    nrow <- if(length(dim(xj)) == 2) dim(xj)[1] else length(xj)
             ## for consistency with S: don't drop (to a list)
             ## if only one row unless explicitly asked for
             drop <- !mdrop && nrow == 1
-            if(drop) {
+            if(drop) { # return list
+		class(x) <- attr(x, "row.names") <- NULL
 		names(x) <- cols
-		attr(x, "row.names") <- NULL
 	    }
 	} else drop <- FALSE ## for n == 0
     }
Thanks anyway, Vladimir!

Regards,
Martin Maechler, ETH Zurich
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to