in_replace {inops}R Documentation

Replacing Values and Intervals

Description

Operators for replacing values within a given interval or set.

Usage

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

# 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")


[Package inops version 0.0.1 Index]