Last chance! 50% off unlimited learning
Sale ends in
This function lets the user do one hot encoding on a variable with comma separated values
ohe_commas(df, ..., sep = ",", noval = "NoVal", remove = FALSE)
Dataframe. May contain one or more columns with comma separated values which will be separated as one hot encoding
Variables. Which variables to split into new columns?
Character. Which regular expression separates the elements?
Character. No value text
Boolean. Remove original variables?
data.frame on which all features are numerical by nature or transformed with one hot encoding.
Other Data Wrangling:
balance_data()
,
categ_reducer()
,
cleanText()
,
date_cuts()
,
date_feats()
,
formatNum()
,
holidays()
,
impute()
,
left()
,
normalize()
,
ohse()
,
removenacols()
,
replaceall()
,
textFeats()
,
textTokenizer()
,
vector2text()
,
year_month()
Other One Hot Encoding:
date_feats()
,
holidays()
,
ohse()
# NOT RUN {
df <- data.frame(
id = c(1:5),
x = c("AA, D", "AA,B", "B, D", "A,D,B", NA),
z = c("AA+BB+AA", "AA", "BB, AA", NA, "BB+AA")
)
ohe_commas(df, x, remove = TRUE)
ohe_commas(df, z, sep = "\\+")
ohe_commas(df, x, z)
# }
Run the code above in your browser using DataLab