From D.A.Wooff@durham.ac.uk  Thu Feb 18 17:09:33 1999
From: D.A.Wooff@durham.ac.uk (D.A.Wooff@durham.ac.uk)
Date: Thu, 18 Feb 1999 18:09:33 +0100
Subject: [R] possible bug in loglm (PR#122)
Message-ID: <199902181709.SAA12157@biostat.ku.dk>

Bug report: there is a problem with loglm (or some underlying code)
when used with updating within a function. For example, this code
works as expected, when used outside a function:


-------------------------------------------------
library(MASS)
cts<-c(25,13,99,45,128,78,151,153,173,171,49,62,1308,236,989,264,622,201,492,244,382,237,122,102,39,5,67,28,53,29,27,20,18,17,1,2,41,11,54,44,64,76,102,83,104,160,41,54,1232,321,1015,348,755,328,530,395,414,370,160,147,25,11,48,20,29,23,20,16,14,11,1,3)

foo<-cbind(expand.grid(f1=factor(c("A","B")),f2=factor(11:16),f3=factor(c("S","N","E")),f4=factor(c("F","M"))),cts=cts)

d0<-loglm(cts~f1+f2+f3+f4,data=foo)
d1<-update(d0,.~.^2)
-------------------------------------------------


but, unless d0 is visible outside the function, 
the same code does not work as expected when within a function:

-------------------------------------------------
rm(list=ls())
library(MASS)

tester<-function(){

cts<-c(25,13,99,45,128,78,151,153,173,171,49,62,1308,236,989,264,622,201,492,244,382,237,122,102,39,5,67,28,53,29,27,20,18,17,1,2,41,11,54,44,64,76,102,83,104,160,41,54,1232,321,1015,348,755,328,530,395,414,370,160,147,25,11,48,20,29,23,20,16,14,11,1,3)

foo<-cbind(expand.grid(f1=factor(c("A","B")),f2=factor(11:16),f3=factor(c("S","N","E")),f4=factor(c("F","M"))),cts=cts)

d0<-loglm(cts~f1+f2+f3+f4,data=foo)
d1<-update(d0,.~.^2)
}

tester()
-------------------------------------------------

results in the message:

Error: Object "foo" not found




David.

---------------------------------------------------------------------
  David Wooff, Director, Statistics and Mathematics Consultancy Unit,
  Department of Mathematical Sciences, University of Durham.
  Science Laboratories, South Road, Durham, DH1 3LE, UK.
  Tel. 0191 374 4531, Fax 0191 374 7388.
---------------------------------------------------------------------
  


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[R] possible bug in loglm (PR#122)
D.A.Wooff@durham.ac.uk