From berwin at maths.uwa.edu.au  Mon Mar  8 09:17:51 2004
From: berwin at maths.uwa.edu.au (berwin@maths.uwa.edu.au)
Date: Mon Mar  8 09:17:50 2004
Subject: [Rd] Bug in points.formula (PR#6652)
Message-ID: <20040308081751.5C872EFB2@slim.kubism.ku.dk>

Dear all,

I noticed the following bug in points.formula

> library(DAAG)
> data(roller)
> fm <- lm(depression ~ weight, data=roller)
> plot( depression ~ weight, data=roller, type="n")
> abline(fm)
> attach(roller)
> points( depression~weight, subset=1:7)
> points( depression~weight, subset=8:10, col="blue")
Error in if (length(x) == l) x[s] else x : 
	argument is of length zero

This seems to be due to the fact that the data used was attached
before the call and not specified in the call via the "data"
argument.  The following patch seems to fix the problem.

Cheers,

        Berwin

diff -c /home/berwin/lang/R/Courses/3S6/plot.R.orig /home/berwin/lang/R/Courses/3S6/plot.R
*** /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)
      }



--please do not edit the information below--

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = 
 major = 1
 minor = 8.1
 year = 2003
 month = 11
 day = 21
 language = R

Search Path:
 .GlobalEnv, roller, package:DAAG, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, Autoloads, package:base


[Rd] Bug in points.formula (PR#6652)
berwin@maths.uwa.edu.au