replaceall | R Documentation |
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)
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) |
data.frame with replaced values based on inputs.
Other Data Wrangling:
balance_data()
,
categ_reducer()
,
cleanText()
,
date_cuts()
,
date_feats()
,
file_name()
,
formatHTML()
,
holidays()
,
impute()
,
left()
,
normalize()
,
num_abbr()
,
ohe_commas()
,
ohse()
,
quants()
,
removenacols()
,
replacefactor()
,
textFeats()
,
textTokenizer()
,
vector2text()
,
year_month()
,
zerovar()
Other Text Mining:
cleanText()
,
ngrams()
,
remove_stopwords()
,
sentimentBreakdown()
,
textCloud()
,
textFeats()
,
textTokenizer()
,
topics_rake()
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.