do (version 1.4.0.0)

Replace: Replace

Description

There are two methords in this function. You can use repalce many objects to one by form and to. pattern can be used to one object replaced by the other one.

Usage

Replace(data, from, to, pattern)

Arguments

data

can be number, strings, verctors, dataframe or matrix.

from

replaced stings

to

replacements

pattern

like from:to

Value

replaced data

Examples

Run this code
# NOT RUN {
Replace(data = 232,from = 2,to = 1)
Replace(data = c(232,'a4b'),
        from = c(2,'.*4'),to = 1,
        pattern = c('a:e','b:h'))
df = data.frame(
  a = c(232, 452),
  b = c("nba", "cba")
)
Replace(data = df,
        from = 2,to = 1,
        pattern = c('a:e','b:h'))

# }

Run the code above in your browser using DataLab