new.function <- function(a, b,...)
{
print(a^2)
print(a)
print(b)
argnames <- names(list(...))
args=list(...)
# new.function[1]
}
new.function(64,5,5,6)
f <- function(a, ...) {
argnames <- names(list(...))
print(argnames)
# check whether b is an argument
if(!("c" %in% argnames)) {
c <- 1
}
# check whether d is an argument
if(!("d" %in% argnames)) {
d <- 1
}
# return NA for b and d if specified, but don't set a value
list(a=a, b=ifelse(exists("c"), c, NA), d=ifelse(exists("d"), d, NA),
##args=list(...))
}
f(4,4,42,4,8,4,4,3)
Post a Comment