From: Siegfried.Macho
Dear R-helpers,
I got the following problem with the function hasArg()
I would like to use the function to check whether the
argument "crit" is
present as an argument of the function (here is the
simplified version of
the function):
SDT.Optim <- function(crit = NULL, Hess = F)
{
q <- length(par); x <- data
if(hasArg(crit))
cat("\n Crit present\n")
else
cat("\n Crit not present\n")
}
if I call the function:
Gauss.Obj <- SDT.Optim(Par0, Freq, crit, T)
from the command device the function hasArg() works
correctly. However, if
I use the same call within a R-file, loaded via the function
source(), the
function hasArg() always retuns FALSE.
Q.1: What is the reason of this behavior and how can I change it?
Q.2: Before using hasArg() I tried to test whether the value
of crit is
NULL using the function is.null(crit) This did not work
either (at least
with command files). Why not?
Q.3: What is the best way to check whether crit was transferred as an
argument to the function (that works with R-files called via
source())?
Thank you in advance for your help,
S.M.
==============================================
Dr. Siegfried Macho
Department of Psychology
University of Fribourg
Rue de Faucigny 2
CH-1700 Fribourg
Tel.: +41-26-3007635
Fax.: +41-26-3009712
http://www.unifr.ch/psycho/general/macho.htm
==============================================
[[alternative HTML version deleted]]