Skip to content

Instantly share code, notes, and snippets.

View madilk's full-sized avatar

madilk

View GitHub Profile
#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("")
translation <-
gl_translate(
data$comments,
target = "en",
format = c("text"),
source = "")
@madilk
madilk / ggcorrplot.r
Last active May 5, 2021 16:46
ggcorrrplot - correlation plot in R with Google Analytics data
library(googleAnalyticsR)
ga_auth(json_file = "C:\\folder-where-your-json-is-located\\service-key.json")
account_list$viewId
#pls change id
id <- 1234567
data <- google_analytics(id,
date_range = c("2021-01-01","2021-05-02"),
metrics=c("sessions","bounceRate",
@madilk
madilk / arulesviz plotly for lift visualization
Last active May 26, 2021 20:01
Arules viz - Market Basket Analysis in R Prgramming
#install.packages("plotly")
library(plotly)
plot(rules,engine="plotly")
@madilk
madilk / arules market basket lift visualization in r plus shiny.r
Last active May 26, 2021 20:27
arules market basket lift visualization in r plus shiny
#https://github.com/mhahsler/arulesViz#standard-visualization
#install.packages("shiny")
library(shiny)
#install.packages("shinythemes")
library(shinythemes)
rules <- apriori(tr, parameter = list(support = 0.02, confidence = 0.02))
ruleExplorer(rules)
@madilk
madilk / data studio - group content where page begins with - pattern.md
Last active June 2, 2021 18:30
Datastudio - Group content where page starts with - as pattern

CASE

WHEN REGEXP_MATCH(Page,"((?i).^/blog).") THEN "Blog"

WHEN REGEXP_MATCH(Page,"((?i).^/contact).") THEN "Contact"

ELSE "Other"

END

@madilk
madilk / DataExplorer EDA R package.r
Last active June 10, 2021 15:22
DataExplorer package in R
#pull data from GA API
library(googleAnalyticsR)
#change location of json service key
ga_auth(json_file = "C:\\folder-where-your-service-creds-JSON-is-located\\json-service-key.json")
account_list$viewId
#change view id of
viewID <- 12345678
data <- google_analytics(
viewID,
date_range = c("2020-01-01","2021-06-09"),
@madilk
madilk / pyramid_chart in r prog.r
Created June 21, 2021 20:51
Pyramid chart in R using Google Analytics API plus demographic data [age and gender]
#source R script
#https://thomas-neitmann.github.io/ggcharts/reference/pyramid_chart.html
library(googleAnalyticsR)
#pull data from GA API
library(googleAnalyticsR)
#change location of json service key
ga_auth(json_file = "C:\\secret-folder\\service-key.json")
account_list$viewId
#change view id
viewID <- 12345678
@madilk
madilk / geom_mark_hull.r
Last active June 30, 2021 05:43
ggforce r package with google analytics data: geom_mark_hull
#creator of ggforce package: Thomas Lin Pedersen
#https://ggforce.data-imaginist.com/reference/geom_mark_hull.html
library(googleAnalyticsR)
ga_auth(json_file="C:\\location-of-your-json-file-folder\\service-key.json")
#update your view id
viewID <- 12345678
data <- google_analytics(
viewID,
date_range=c("2019-01-01","2021-06-28"),
@madilk
madilk / modeltime r package for time series forecasts.r
Last active July 6, 2021 21:06
modeltime r package for time series forecasts - google analytics data
# R TIPS ----
# TIP 040 | Introduction to Modeltime: In Under 10-Minutes ----
#By Matt Dancho, modeltime package creator
#R Tips newsletter by Matt Dancho: https://mailchi.mp/business-science/r-tips-newsletter
# LIBRARIES ----
#installing packages from git
#install.packages("devtools")
library(devtools)
library(usethis)