Typically generated by list_rhs.formula(), it contains, in
addition to a list of call() or similar objects information about
the sign of the term and the environment of the formula from which
the term has been extracted, accessible and modifiable via sign()
and envir() generics. Indexing and concatenation methods preserve
these.
Usage
term_list(x, sign = +1L, env = NULL)
as.term_list(x, ...)
# S3 method for class 'term_list'
as.term_list(x, ...)
# Default S3 method
as.term_list(x, sign = +1L, env = NULL, ...)
# S3 method for class 'term_list'
c(x, ...)
# S3 method for class 'term_list'
x[i, ...]
# S3 method for class 'term_list'
print(x, ...)
# S3 method for class 'term_list'
sign(x)
# S3 method for class 'term_list'
sign(x) <- value
# S3 method for class 'term_list'
envir(object)
# S3 method for class 'term_list'
envir(object) <- valueMethods (by generic)
sign(term_list): Anintegervector giving the signs of each term in the list.sign(term_list) <- value: Update the signs of the terms;valueis recycled to the length of the list.envir(term_list): Alistwith an element for each term in the list, giving its environment.envir(term_list) <- value: Update the environments of the terms;valuecan be an environment or a list of environments, recycled to the length of the term list.
Examples
e1 <- new.env()
f1 <- a~b+c
environment(f1) <- e1
f2 <- ~-NULL+1
(l1 <- list_rhs.formula(f1))
#> Term List:
#> + b <environment: 0x5754bcbb4610>
#> + c <environment: 0x5754bcbb4610>
(l2 <- list_rhs.formula(f2))
#> Term List:
#> - NULL <environment: 0x5754bcba0e98>
#> + 1 <environment: 0x5754bcba0e98>
(l <- c(l1,l2))
#> Term List:
#> + b <environment: 0x5754bcbb4610>
#> + c <environment: 0x5754bcbb4610>
#> - NULL <environment: 0x5754bcba0e98>
#> + 1 <environment: 0x5754bcba0e98>
#> Error: identical(envir(l), rep(list(e1, globalenv()), each = 2)) is not TRUE
(l <- c(l2[1], l1[2], l1[1], l1[1], l2[2]))
#> Term List:
#> - NULL <environment: 0x5754bcba0e98>
#> + c <environment: 0x5754bcbb4610>
#> + b <environment: 0x5754bcbb4610>
#> + b <environment: 0x5754bcbb4610>
#> + 1 <environment: 0x5754bcba0e98>
sign(l)[3] <- -1L
#> Error: identical(envir(l), list(globalenv(), e1, e1, e1, globalenv())) is not TRUE