我已经通过R从Google Analytics(分析)API中提取了数据。
指标是日期,登录页面和用户
通过R提取数据
g<- p %>% group_by(landingPagePath="/pricing/")
View(g)
输出
date |landing page |users
---------------------------------
2019-01-14 | /pricing/ |3
2019-01-14 | /pricing/ |1
2019-01-14 | /pricing/ |1
2019-01-15 | /pricing/ |4
2019-01-15 | /pricing/ |1
2019-01-16 | /pricing/ |10
我需要输出为:
date |users
---------------------------------
2019-01-14 | 5
2019-01-15 | 5
2019-01-16 | 10
我已经尝试了代码,但是输出为No data Available
gv <- g %>%group_by(date='2018-01-14') %>% filter(users==sum(users))
答案 0 :(得分:0)
您可以使用 数据
df <-read.table(text="date landing_page users
14-01-2019 pricing 3
14-01-2019 pricing 1
14-01-2019 pricing 1
15-01-2019 pricing 4
15-01-2019 pricing 1
16-01-2019 pricing 10
",header = T)
str(df)
结果
library(lubridate)
df$date <-dmy(df$date)
df1 <- aggregate(users ~ date,df , sum)