isargunnamed: Is an element of a list named?

View source: R/args.R

isargunnamedR Documentation

Is an element of a list named?

Description

Check if a component of a list is not named.

Usage

isargunnamed(x, k)

Arguments

x

a list.

k

an integer, specifies a position in x.

Details

isargunnamed(x,k) returns TRUE if the k-th component of x is not named and FALSE otherwise.

Argument x is typically a list of arguments used in a call to a function, such as the one obtained by list(...) in the body of a function definition.

If k is not positive, isargunnamed returns FALSE.

Value

TRUE or FALSE

Author(s)

Georgi N. Boshnakov

See Also

match.call in base package

Examples

li1 <- list(a=1, 2, 3)
isargunnamed(li1, 1)
isargunnamed(li1, 2)

## wholly unnamed list
li2 <- list(1, 2, 3)
isargunnamed(li2, 1)
isargunnamed(li2, 2)

## using in a function definition
f1 <- function(...){
    dots <- list(...)
    for(i in seq(along=dots))
        cat(i, isargunnamed(dots, i), "\n")
}

f1(1)
f1(a = 3, 4, c = 5)
f1(x = "a", y = "b")

gbutils documentation built on May 28, 2022, 1:13 a.m.