[R] last.warning and function problem

Huntsinger, Reid reid_huntsinger at merck.com
Tue Nov 5 21:45:28 CET 2002


Inside the function the environment doesn't contain last.warning. 
The "exists" function by default checks parent environments 
(inherits=TRUE) but wisely, "rm" doesn't (inherits=FALSE). You just
need to change the default for "rm" to get the desired behavior.

Reid Huntsinger

-----Original Message-----
From: Marta Rufino [mailto:mrufino at cmima.csic.es]
Sent: Tuesday, November 05, 2002 10:53 AM
To: r-help at stat.math.ethz.ch
Subject: [R] last.warning and function problem


Hello,

I am a newbie in R and I am trying to create a function, that includes
several functions inside.
To avoid that everything stops if there is an error, I have this statement 

bla = function(....){
...
if(exists("last.warning")){rm(last.warning)}
...
}

inside the function, which if I use it normally, it works fine, but once I
use it with the funciotn it gives me an error like:

$"remove: variable "last.warning" was not found"
NULL

which breaks my function.
I just want to make it do: if exists the file last warning, remove it, if
not, just proceed...
Does anyone knows why this happens? How can I avoid it?
Thanks in advance.
Marta 
    

><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>
`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´

Marta Rufino

Centre Mediterrani d'Investigacions Marines i Ambientals
(CMIMA). CSIC
Passeig Maritim 37-49
08003  BARCELONA

Tfno:34 93 230 95 40
Tfax:34 93 230 95 55

><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>
`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>`·.¸¸.·´


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list