Last active
March 13, 2021 18:10
-
-
Save madilk/b56af472a11a0e4277bf372d0cad875c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#visualize in ggplot | |
ggplot(R1, aes(channel_name, value, fill = variable)) + | |
geom_bar(stat='identity', position='dodge') + | |
ggtitle('TOTAL CONVERSIONS') + | |
theme(axis.title.x = element_text(vjust = -2)) + | |
theme(axis.title.y = element_text(vjust = +2)) + | |
theme(title = element_text(size = 16)) + | |
theme(plot.title=element_text(size = 20)) + | |
ylab("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install the packages | |
install.packages("ChannelAttribution") | |
install.packages("reshape") | |
install.packages("ggplot2") | |
#run libraries | |
library(ChannelAttribution) | |
library(reshape) | |
library(ggplot2) | |
Data <- read.csv("C:\\your sub folder\\markov chain test.csv",sep=",") | |
ChData <- as.data.frame(Data) | |
View(ChData) | |
head(ChData) | |
summary(ChData) | |
#regular models> first touch , last touch, linear | |
H <- heuristic_models(ChData, 'ï..path', 'total_conversions','total_conversion_value') | |
#markov model | |
M <- markov_model(ChData, 'ï..path', 'total_conversions', var_value='total_conversion_value', order = 1, var_null = 'total_null') | |
R <- merge(H, M, by='channel_name') | |
R1 <- R[, (colnames(R)%in%c('channel_name', 'first_touch_conversions', 'last_touch_conversions', 'linear_touch_conversions', 'total_conversion'))] | |
colnames(R1) <- c('channel_name', 'first_touch', 'last_touch', 'linear_touch', 'markov_model') | |
R1 <- melt(R1, id='channel_name') | |
#visualize in ggplot | |
ggplot(R1, aes(channel_name, value, fill = variable)) + | |
geom_bar(stat='identity', position='dodge') + | |
ggtitle('TOTAL CONVERSIONS') + | |
theme(axis.title.x = element_text(vjust = -2)) + | |
theme(axis.title.y = element_text(vjust = +2)) + | |
theme(title = element_text(size = 16)) + | |
theme(plot.title=element_text(size = 20)) + | |
ylab("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#regular models> first touch , last touch, linear | |
H <- heuristic_models(ChData, 'ï..path', 'total_conversions','total_conversion_value') | |
#markov model | |
M <- markov_model(ChData, 'ï..path', 'total_conversions', var_value='total_conversion_value', order = 1, var_null = 'total_null') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install the packages | |
install.packages("ChannelAttribution") | |
install.packages("reshape") | |
install.packages("ggplot2") | |
#run libraries | |
library(ChannelAttribution) | |
library(reshape) | |
library(ggplot2) | |
Data <- read.csv("C:\\Your sub folder\\markov chain test.csv",sep=",") | |
ChData <- as.data.frame(Data) | |
View(ChData) | |
head(ChData) | |
summary(ChData) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R <- merge(H, M, by='channel_name') | |
R1 <- R[, (colnames(R)%in%c('channel_name', 'first_touch_conversions', 'last_touch_conversions', 'linear_touch_conversions', 'total_conversion'))] | |
colnames(R1) <- c('channel_name', 'first_touch', 'last_touch', 'linear_touch', 'markov_model') | |
R1 <- melt(R1, id='channel_name') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment