Learn R Programming

lares (version 4.8.4)

date_feats: One Hot Encoding for Date/Time Variables (Dummy Variables)

Description

This function lets the user automatically create new columns out of a dataframe or vector with date/time variables.

Usage

date_feats(
  dates,
  keep_originals = FALSE,
  only = NA,
  features = TRUE,
  holidays = FALSE,
  country = "Venezuela",
  currency_pair = NA,
  summary = TRUE
)

Arguments

dates

Vector or dataframe. Non-date/time columns will be automatically ignored/extracted.

keep_originals

Boolean. Should the original date/time columns be kept in the results? Only valid when input is a dataframe.

only

Character or vector. Which columns do you wish to process? If non are explicitly defined, all will be processed

features

Create features out of date/time columns?

holidays

Boolean. Include holidays as new columns?

country

Character or vector. For which countries should the holidays be included?

currency_pair

Character. Which currency exchange do you wish to get the history from? i.e, USD/COP, EUR/USD...

summary

Boolean. Print a summary of the operations?

See Also

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

Other Feature Engineering: holidays(), ohse()

Other One Hot Encoding: holidays(), ohse()

Examples

Run this code
# NOT RUN {
data(dfl) # Dummy dataset
# Imput as a vector or dataframe
df <- date_feats(dfl, keep_originals = TRUE)
# Same as running date_feats(dfl$opp_date)
head(df, 10)
# }

Run the code above in your browser using DataLab