Learn R Programming

numform (version 0.7.0)

fv_runs: Remove Subsequent Runs from a Vector

Description

Remove subsequent runs from a vector.

Usage

fv_runs(x, fill = "", missing = NA, ...)

Arguments

x

A vector with runs.

fill

What to fill in subsequent runs with.

missing

What to fill in missing values with.

ignored.

Value

Returns a vector of strings with subsequent runs removed.

Examples

Run this code
# NOT RUN {
x <- c(1, 1 , 2, 3, 4, 4, 1, 1, 3, 3, NA, 5)
fv_runs(x)
fv_runs(x, fill = '-')
fv_runs(x, fill = '-', missing = 'X')

# }
# NOT RUN {
library(dplyr)

set.seed(10)
data.frame(
    state = sort(sample(state.name[c(1, 5, 9, 12)], 12, TRUE)),
    val = rnorm(12)
) %>%
    mutate(state2 = fv_runs(state))
# }

Run the code above in your browser using DataLab