Debian Codegraph @

man/attr-operators.Rd

raw
1 \name{attr-operators}
2 \alias{\%#\%}
3 \alias{\%##\%}
4 \alias{\%@\%}
5 \alias{\%@\%<-}
6 \title{Operators for Setting Annotations and Attributes}
7 \description{The operator \code{\%#\%} can be used to attach a
8 \code{\link{description}} annotation to an object. \code{\%##\%} can be
9 used to attach a character vector of annotations to an object.
10 \code{\%@\%} returns the attribute with the name given as second
11 argument. With \code{\%@\%} it is also possible to assign attributes.
12 }
13 \usage{
14 x \%#\% descr
15 x \%##\% annot
16 x \%@\% nm
17 x \%@\% nm <- value
18 }
19 \arguments{
20 \item{x}{an object, usually and \code{\link{item}} or a vector.}
21 \item{descr}{a character string}
22 \item{annot}{a named character vector; its contents are added to the
23 "annotation" attribute of \code{x}. Existing elements are kept.}
24 \item{nm}{a character string, the name of the attribute being set or
25 requested.}
26 \item{value}{any kind of object that can be attached as an attribute.}
27 }
28 \examples{
29 test1 <- 1 \%#\% "One"
30 # This is equivalent to:
31 # test <- 1
32 # description(test) <- "One"
33 description(test1)
34 # Results in "One"
35
36 # Not that it makes sense, but ...
37 test2 <- 2 \%##\% c(
38 Precedessor = 0,
39 Successor = 2
40 )
41 # This is equivalent to:
42 # test2 <- 2
43 # annotation(test2) <- c(
44 # Precedessor = 0,
45 # Successor = 2
46 # )
47 annotation(test2)
48
49 # The following examples are equivalent to
50 # attr(test2,"annotation")
51 test2 \%@\% annotation
52
53 test2 \%@\% "annotation"
54
55 test2 \%@\% another.attribute <- 42
56 # This is equivalent to attr(test2,"another.attribute") <- 42
57
58 attributes(test2)
59 }