 <R-help@lists.r-project.org>Hi, i'm tryng to build a function that take
some input from user and if the user doesn't provide that inputs the
function should set a deafult value. I have taken as example a function that
i found in the package dlm but with the same code i receive an error (the
component is missing...). According to the code below R seems to set 1 to
"phi" instead of "p" ! The only way to solve this problem that i found is to
change "p" to "P", but this is clearly the wrong solution ! There is some
other way to set default value with that function structure ?
Thanks,
Marco

------------

Stem.Skeleton <- function(...) {

    if (nargs() == 1)

        x <- as.list(...)

    else

        x <- list(...)


    ## required components

    comp <- c("phi", "p", "K")

if(is.null(list(x$p))) x$p = 1

compInd <- match(comp, names(x))

   if (any(is.na(compInd)))

        stop(paste("Component(s)", paste(comp[is.na(compInd)], collapse=", "
),

                   "is (are) missing"))
....
---------

	[[alternative HTML version deleted]]

