Description Usage Arguments Examples
User sets adstock rates, which transforms the input variable, outputting in a new table.
1 | adstock.multiple(data, variable, adstock.rates)
|
data |
data.table that holds the variable to be transformed |
variable |
Character string of the variable to be transformed |
adstock.rates |
One (or many) rates to adstock the variable |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | x <- data.table::fread(system.file("extdata", "TVRs.csv", package = "nladwa"))
out1 <- adstock.multiple(data = x, variable = "TVRs", adstock.rates = 0.1)
out2 <- adstock.multiple(data = x, variable = "TVRs", adstock.rates = seq(from = 0.1, to = 0.9, by = 0.1))
out1[, Index := 1:nrow(out1)]
out2[, Index := 1:nrow(out2)]
plot.out1 <- data.table::melt(out1, id.vars = "Index")
ggplot2::ggplot(plot.out1, ggplot2::aes(x = Index, y = value, colour = variable)) +
ggplot2::geom_line()
plot.out2 <- data.table::melt(out2, id.vars = "Index")
ggplot2::ggplot(plot.out2, ggplot2::aes(x = Index, y = value, colour = variable)) +
ggplot2::geom_line()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.