Assign with type checking

Share:

Description

Assign with type checking

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
atomic(x, ...) <- value

integer(x, ...) <- value

numeric(x, ...) <- value

double(x, ...) <- value

logical(x, ...) <- value

character(x, ...) <- value

raw(x, ...) <- value

complex(x, ...) <- value

matrix(x, ...) <- value

array(x, ...) <- value

list(x, ...) <- value

pairlist(x, ...) <- value

envir(x, ...) <- value

name(x, ...) <- value

symbol(x, ...) <- value

call(x, ...) <- value

factor(x, ...) <- value

fun(x, ...) <- value

expression(x, ...) <- value

language(x, ...) <- value

object(x, ...) <- value

table(x, ...) <- value

recursive(x, ...) <- value

vector(x, ...) <- value

data.frame(x, ...) <- value

null(x, ...) <- value

check(x, ...) <- value

Arguments

x

symbol

...

additional conditions taking the following forms:

1. fun = v, i.e. fun(x) must be equal v.

2. cond, i.e. cond(x) must be TRUE.

3. a function like function(x) mean(x) <= 5.0

value

value to be assigned

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
x <- 10L
atomic(x) <- 20
numeric(x) <- 10
numeric(x, length = 10L) <- 1:10

cond1 <- function(x) mean(x) <= 5
numeric(x, cond1) <- 0:9

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.