replaceall: Replace Values With

Description Usage Arguments Value See Also Examples

Description

This function lets the user replace all specific values in a vector or data.frame into another value. If replacing more than one value, order matters so they will be replaced in the same order that you pass them to the function. Factors will be refactored.

Usage

1
replaceall(df, original, change, which = "all", fixclass = TRUE, quiet = TRUE)

Arguments

df

Data.frame or Vector

original

String or Vector. Original text you wish to replace

change

String or Vector. Values you wish to replace the originals with

which

Character vector. Name of columns to use. Leave "all" for everything

fixclass

Boolean. Try to detect logical classes after transformations (or leave as default classes as character)?

quiet

Boolean. Keep quiet? (or print replacements)

Value

data.frame with replaced values based on inputs.

See Also

Other Data Wrangling: balance_data(), categ_reducer(), cleanText(), date_cuts(), date_feats(), formatNum(), holidays(), impute(), left(), normalize(), numericalonly(), ohe_commas(), ohse(), removenacols(), removenarows(), textFeats(), textTokenizer(), vector2text(), year_month(), year_week()

Other Text Mining: cleanNames(), cleanText(), ngrams(), remove_stopwords(), sentimentBreakdown(), textCloud(), textFeats(), textTokenizer(), topics_rake()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
df <- data.frame(one = c(1:4, NA), 
                 two = LETTERS[1:5], 
                 three = rep("A", 5), 
                 four = c(NA, "Aaa", 123, "B", "C"))
print(df)

replaceall(df, "A", NA)

replaceall(df, "A", "a")

replaceall(df, 1, "*")

replaceall(df, NA, "NotNA")

replaceall(df, NA, 0)

replaceall(df, c("A", "B"), c("'A'", "'B'"))

replaceall(df, "a", "*", which = "four")

lares documentation built on June 9, 2021, 9:06 a.m.