R: Depreciated _collapse_ Functions

collapse-depreciated {collapse} | R Documentation

## Depreciated collapse Functions

### Description

The functions `Recode` and `replace_non_finite` available until collapse v1.1.0 will be removed soon. Since v1.2.0, `Recode` is replaced by `recode_num` and `recode_char` and `replace_non_finite` is replaced by `replace_Inf`. Since version 1.5.1, `is.regular` is depreciated - the function is not very useful and clashes with a more important one in the zoo package.

### Usage

    Recode(X, ..., copy = FALSE, reserve.na.nan = TRUE, regex = FALSE)

    replace_non_finite(X, value = NA, replace.nan = TRUE)

    is.regular(x)

### Arguments

`X` | a vector, matrix or data frame.
`x` | an R object.
`...` | comma-separated recode arguments of the form: `name = newname, `2` = 0, `NaN` = 0, `NA` = 0, `Inf` = NA, `-Inf` = NA`, etc...
`value` | a single (scalar) value to replace matching elements with. Default is `NA`.
`copy` | logical. For reciprocal or sequential replacements of the form `a = b, b = c` make a copy of `X` to prevent `a` being replaced with `b` and then all `b`-values being replaced with `c` again. In general `Recode` does the replacements one-after the other, starting with the first.
`reserve.na.nan` | logical. `TRUE` identifies `NA` and `NaN` as special numeric values and does the correct replacement. `FALSE` will treat `NA/NaN` as strings, and thus not match numeric `NA/NaN`. Note: This is not an issue for `Inf/-Inf`, which are matched in both numeric and character variables.
`regex` | logical. If `TRUE`, all recode-argument names are (sequentially) passed to `grepl` as a pattern to search `X`. All matches are replaced.
`replace.nan` | logical. `TRUE` (default) replaces `NaN/Inf/-Inf`. `FALSE` replaces only `Inf/-Inf`.

### Note

`Recode` is not suitable for recoding factors or other classed objects / columns, it simply does `X[X == value] <- replacement` in a more efficient way. For classed objects, see for example `dplyr::recode`.

### See Also

Recode and Replace Values, Collapse Overview

### Examples

    ## Not run:
    Recode(c("a","b","c"), a = "b", b = "c")
    Recode(c("a","b","c"), a = "b", b = "c", copy = TRUE)
    Recode(c("a","b","c"), a = "b", b = "a", copy = TRUE)
    Recode(month.name, ber = NA, regex = TRUE)
    mtcr <- Recode(mtcars, `0` = 2, `4` = Inf, `1` = NaN)
    replace_non_finite(mtcr)
    replace_non_finite(mtcr, replace.nan = FALSE)

    ## End(Not run)

[Package collapse version 1.7.6 Index]