>>>>> "BeT" == Berwin A Turlach <[EMAIL PROTECTED]> >>>>> on Mon, 8 Mar 2004 09:17:51 +0100 (CET) writes:
BeT> Dear all, I noticed the following bug in points.formula <...> BeT> Error in if (length(x) == l) x[s] else x : argument is BeT> of length zero Thank you, Berwin. The bug is still present in current "R-1.9.0 alpha" and can be demonstrated with the slightly simpler code roller <- data.frame(weight = c(1.9, 3.1, 3.3, 4.8, 5.3, 6.1, 6.4, 7.6, 9.8, 12.4), depression = c(2, 1, 5, 5, 20, 20, 23, 10, 30, 25)) plot( depression ~ weight, data=roller, type="n") with(roller, points( depression~weight, subset=1:7 )) # ok with(roller, points( depression~weight, subset=8:10)) # ok with(roller, points( depression~weight, subset=8:10, col=2))## --> Error BeT> This seems to be due to the fact that the data used was BeT> attached before the call and not specified in the call BeT> via the "data" argument. Yes, using "data =" doesn't show the problem, but as you see, the problem also shows for the more recommended way of using with() instead of attach().. BeT> The following patch seems to fix the problem. *** /home/berwin/lang/R/Courses/3S6/plot.R.orig Tue Sep 2 23:43:42 2003 --- /home/berwin/lang/R/Courses/3S6/plot.R Mon Mar 8 16:06:32 2004 *************** *** 312,318 **** mf <- eval(m, parent.frame()) if (!missing(subset)) { s <- eval(m$subset, data, parent.frame()) ! l <- nrow(data) dosub <- function(x) if (length(x) == l) x[s] else x dots <- lapply(dots, dosub) } --- 312,320 ---- mf <- eval(m, parent.frame()) if (!missing(subset)) { s <- eval(m$subset, data, parent.frame()) ! mtmp <- m ! mtmp$subset <- NULL ! l <- nrow(eval(mtmp, parent.frame())) dosub <- function(x) if (length(x) == l) x[s] else x dots <- lapply(dots, dosub) } ------------------- Yes, but the resulting code becomes even more ugly. doing a second eval(m, ..) just with a slightly modified 'm'... Though I'll have to leave it to others to find if there is a better patch... Thanks again, Berwin! Martin ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel