Extract {refer} | R Documentation |
Extract or Replace Parts of a Referenced Object
Description
Operators acting on a ref
object that extract part of the underlying object
at the supplied indices, or replaces parts. These operators modify or extract from the
object that is referenced, not the reference! Use sref
is this behavior
is undesirable.
Usage
## S3 method for class 'ref'
x$name
## S3 method for class 'sref'
x$..., value
## S3 replacement method for class 'ref'
x$name <- value
## S3 replacement method for class 'sref'
x$... <- value
## S3 method for class 'ref'
x[...]
## S3 method for class 'sref'
x[..., value]
## S3 replacement method for class 'ref'
x[...] <- value
## S3 replacement method for class 'sref'
x[...] <- value
## S3 method for class 'ref'
x[[...]]
## S3 method for class 'sref'
x[[..., value]]
## S3 replacement method for class 'ref'
x[[...]] <- value
## S3 replacement method for class 'sref'
x[[...]] <- value
Arguments
x |
object of class |
name |
literal character string or a name |
... |
values passed to the function after dereferencing |
value |
object, usually of a similar class as the dereferenced value of |
Value
Object of class "ref"
Examples
x <- list(
a = 1,
b = "hello",
"world"
)
ref_to_x <- ref(x)
# Extract parts of 'x' from the reference
ref_to_x$a
ref_to_x[2:3]
ref_to_x[["b"]]
# Replace parts of 'x' through the reference
ref_to_x[["a"]] <- 100
x$a == 100
ref_to_x$b <- "bye"
x$b == "bye"
ref_to_x[2:3] <- list(2, 3)
print(x)
[Package refer version 0.1.0 Index]