I try run the following function in R:
GainChart <- function(score, good.label, n.breaks = 50, ...){
df <- data.frame(percentiles = seq(0, 1, length = n.breaks),
gain = Gain(score, good.label, seq(0, 1, length = n.breaks)))
p <- ggplot(df, aes(percentiles, gain)) + geom_line(size = 1.2, colour = "darkred")
p <- p + geom_line(aes(x = c(0,1), y = c(0,1)), colour = "gray", size = 0.7)
p <- p + scale_x_continuous("Sample Percentiles", labels = percent_format(), limits = c(0, 1))
p <- p + scale_y_continuous("Cumulative Percents of Bads", labels = percent_format(), limits = c(0, 1))
p
}
And I received the following error message: "Error: Aesthetics must be either length 1 or the same as the data (50): x, y"
The command for call the function is:
GainChart(data_sampni$score,data_sampni$TOPUP_60d)