Skip to contents

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

Georgi N. Boshnakov

See also

match.call in base package

Examples

li1 <- list(a=1, 2, 3)
isargunnamed(li1, 1)
#> [1] FALSE
isargunnamed(li1, 2)
#> [1] TRUE

## wholly unnamed list
li2 <- list(1, 2, 3)
isargunnamed(li2, 1)
#> [1] TRUE
isargunnamed(li2, 2)
#> [1] TRUE

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

f1(1)
#> 1 TRUE 
f1(a = 3, 4, c = 5)
#> 1 FALSE 
#> 2 TRUE 
#> 3 FALSE 
f1(x = "a", y = "b")
#> 1 FALSE 
#> 2 FALSE