in_replace: Replacing Values and Intervals

Description Usage Arguments Details Value See Also Examples

Description

Operators for replacing values within a given interval or set.

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
x %in{}% table <- value

x %out{}% table <- value

x %in[]% interval <- value

x %out[]% interval <- value

x %in()% interval <- value

x %out()% interval <- value

x %in(]% interval <- value

x %out(]% interval <- value

x %in[)% interval <- value

x %out[)% interval <- value

x %in~% pattern <- value

x %out~% pattern <- value

x %in~f% pattern <- value

x %out~f% pattern <- value

x %in~p% pattern <- value

x %out~p% pattern <- value

x %in% table <- value

x %out% table <- value

x %in#% count <- value

x %out#% count <- value

Arguments

x

vector or array of values to be matched.

table

vector or list to be matched against.

value

replacement value.

interval

numeric vector defining a range to be matched against.

pattern

pattern to be matched against.

count

numeric vector defining counts for count-based selection.

Details

For each %*%<- operator of this package x %*% y <- value is a shorthand for x[x %*% y] <- value.

Value

x with specified values replaced with value.

See Also

%in{}%

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# interval replacement operators
x <- 1:10
x %in[]% c(3,7) <- 0
x

x <- 1:10
x %in[)% c(3,7) <- NA
x

x <- 1:10
x %out[)% c(3,7) <- x
x

# regular expression replacement operators
region <- as.character(state.region)
table(region)
region %in~% "^North" <- "North"
table(region)

# count based replacement operators
carb <- mtcars$carb
table(carb, useNA="always")
carb %in#% 1 <- NA
table(carb, useNA="always")

inops documentation built on Nov. 19, 2019, 5:08 p.m.