Learn R Programming

scorecardModelUtils (version 0.0.1.0)

fn_target: Redefines target value

Description

The function redefines the "binary" target variable to be used for modelling. It takes the variable or field name of the target and the event class. It changes the target field name to "Target", changes the events into 1 and non-events as 0 and places the target column at the end of the dataframe before returning it as output.

Usage

fn_target(base, target, event)

Arguments

base

input dataframe

target

column / field name for the target variable, to be passed as string

event

the event class, to be passed as string

Value

The function returns a dataframe after changing the target classes to 0 or 1.

Examples

Run this code
# NOT RUN {
data <- iris
data$Species <- as.character(data$Species)
data$Y <- sample(0:1,size=nrow(data),replace=TRUE)

data2 <- fn_target(base = data,target = "Y",event = 1)
# }

Run the code above in your browser using DataLab