R
GA
googleAnalyticsR
API
library(googleAnalyticsR)
ga_auth() # This will open a webpage, plz log into your Google Analytics account and paste the athorize code in your R console
1 # Select the current account for analysis
Learn More →
my_accounts <- ga_account_list() # GA account內所有資源列表
View(my_accounts) # 查看帳號擁有的資源/檢視
my_id <- 123456789 # 紀錄要使用的網站viewId
注意!因為是免費版,一次只能Query 1000筆資料。
但是仍能通過設定時間、抽樣方式,取得一個時段的連續資料(好比爬蟲),因此還是很powerful的。
google_analytics(
my_id,
date_range = c("2018-01-01", "2018-12-31"),
samplingLevel = "SMALL",
metrics = c("sessions", "users", "pageviews", "bounceRate"),
dimensions = c("date", "source", "medium",
"landingPagePath", "pagePath",
"hour","minute"))
【範例】分析從4/26~4/30每日流量來源的媒體,並以長條圖的方式呈現。
df %>%
count(date, sessions, medium) %>%
mutate(sessions = sessions*n) %>%
ggplot(data=df, aes(x=date, y=sessions, fill=medium)) +
geom_col(show.legend = F) -> p
ggplotly(p)
Learn More →
Other Reference: Rpubs R Markdown Theme date: '`r Sys.Date()`' output: rmdformats::material # readthedown date: "`r Sys.Date()`" output: prettydoc::html_pretty:
Aug 3, 2022Reference: http://ccckmit.wikidot.com/st:test1 d = density function 連續型 p = cumulative distribution function 離散 q = quantile function r = random number generation # 累積的常態機率分布 pnorm(175, mean = 170, sd = 5) - pnorm(170, 170, 5) # 計算170到175中間的那塊常態分布面積(mean:170, x:175, sd:5)
Nov 1, 2021Reference: Michael Hahsler(2011). "recommenderlab: A Framework for Developing and Testing Recommendation Algorithms." 推薦系統基本觀念—Collaborative Filtering(協同式過濾) 1. User-based Collaborative Filtering(UBCF) Memory-based CF 採用「全部」或巨量的使用者資料去進行推薦→佔記憶體 推薦系統通常是在線上進行運算,因此上述特性會不利於演算速度 原理
Aug 24, 2020Reference: Ebook Dataset: 古騰堡書庫 Regex in R 尋找 符號 舉例
Jun 20, 2020or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up