# NOT RUN {
# Prepare data frame
df <- data.frame(
gender = rep(c("M", "F"), 5),
age = (1:10)*10,
cost = (51:60),
impression = (101:110),
click = (0:9)*3
)
# Define metrics
metrics <- mmetrics::define(
cost = sum(cost),
ctr = sum(click)/sum(impression)
)
# Evaluate
mmetrics::add(df, gender, metrics = metrics)
# }
Run the code above in your browser using DataLab