#Extract store names in dplyr via mutate
data_store<- data%>%
mutate(Store=
ifelse(str_detect(OrderId, "US"),"US",
ifelse(str_detect(OrderId, "CA"),"CA",
ifelse(str_detect(OrderId, "UK"),"UK",
"Other"))))
View(data_store)
options(scipen = 100) | |
install.packages("CausalImpact") | |
library(CausalImpact) | |
##YT video on running it in R : https://www.youtube.com/watch?v=H64ucBjgY6w | |
View(causaldata) | |
#convert data to time series | |
campaign_mkt <- ts(causaldata$sales) | |
non_campaign_mkt_1 <- ts(causaldata$sales_non_campaign_mkt_1) | |
non_campaign_mkt_2 <- ts(causaldata$sales_non_campaign_mkt_2) |
#Extract store names in dplyr via mutate
data_store<- data%>%
mutate(Store=
ifelse(str_detect(OrderId, "US"),"US",
ifelse(str_detect(OrderId, "CA"),"CA",
ifelse(str_detect(OrderId, "UK"),"UK",
"Other"))))
View(data_store)
#Padr package method | |
#https://statisticsglobe.com/insert-rows-for-missing-dates-in-r | |
#install.packages("padr") | |
library(padr) | |
offerdata_padr <- pad(offerdata) | |
View(offerdata_padr) | |
#https://www.statology.org/dplyr-replace-na-with-zero/ | |
#Add rows for missing dates and replace NAs with zero | |
offerdata2<- offerdata%>% | |
complete(Date = seq.Date(min(Date), max(Date), by="day"))%>% |
# 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) |
#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"), |
#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 |
#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"), |
CASE
WHEN REGEXP_MATCH(Page,"((?i).^/blog).") THEN "Blog"
WHEN REGEXP_MATCH(Page,"((?i).^/contact).") THEN "Contact"
ELSE "Other"
END
#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) |
#install.packages("plotly") | |
library(plotly) | |
plot(rules,engine="plotly") |