Last chance! 50% off unlimited learning
Sale ends in
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.
replaceall(df, original, change, which = "all", fixclass = TRUE, quiet = TRUE)
Data.frame or Vector
String or Vector. Original text you wish to replace
String or Vector. Values you wish to replace the originals with
Character vector. Name of columns to use. Leave "all" for everything
Boolean. Try to detect logical classes after transformations (or leave as default classes as character)?
Boolean. Keep quiet? (or print replacements)
data.frame with replaced values based on inputs.
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()
# NOT RUN {
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")
# }
Run the code above in your browser using DataLab