Extract: Extract or Replace Parts of a Referenced Object

Description Usage Arguments Value Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## 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 "ref"

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 x, used for assigning in place

Value

Object of class "ref"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

refer documentation built on Nov. 8, 2021, 5:08 p.m.