RE: R-alpha: bug in save

Martyn Plummer (martyn@hobbes.iarc.fr)
Wed, 12 Feb 1997 17:02:15 +0100 (MET)


Date: Wed, 12 Feb 1997 17:02:15 +0100 (MET)
From: Martyn Plummer <martyn@hobbes.iarc.fr>
To: friedrich.leisch@ci.tuwien.ac.at
Subject: RE: R-alpha: bug in save


On 12-Feb-97 friedrich.leisch@ci.tuwien.ac.at wrote:

>`save' seems to have the following bug: I cannot save variables that
>were created in a function, i.e.
>
>       myfirstsave <- function(x){
>         save(x, file="whatever")
>       }
>
>works fine, but
>
>       myothersave <- function(x){
>         y<-x
>         save(y, file="whatever")
>       }
>
>results in
>
>R> myothersave(1)
>Error: Object "y" not found

In fact neither myfirstsave nor myothersave works, unless you have
previously defined an object named "x" or "y" respectively.  In this
case both functions save the value of that object and not the value of
the argument x. For example:

R> x <- "Something completely different"
R> myfirstsave(1)
R> rm(x)
R> load("whatever")
R> x
[1] "Something completely different"

It seems that "save" saves objects in the global environment
and not the calling environment. This looks more like a feature
than a bug to me, but a warning message might be appropriate.

Martyn
----------------------------------
E-Mail: Martyn Plummer <martyn@hobbes.iarc.fr>
Date: 12-Feb-97
Time: 18:03:08

This message was sent by XF-Mail
----------------------------------
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-