在RGoogleAnalytics过滤器中排除(未设置)

时间:2017-07-22 00:44:59

标签: r

我正在使用突出显示的以下过滤器运行R脚本:

query.list <- Init(start.date = as.character(startdate),
               end.date = as.character(enddate),
               dimensions = 
"ga:date,ga:campaign,ga:adwordsCampaignID,ga:adGroup,ga:adDestinationUrl",
               metrics = "ga:sessions,ga:bounces",
               max.results = 10000,
               **filters = 
c("ga:adwordsCampaignID!=%28not%20set%29;ga:sessions>0"),**
               table.id = example)

ga.query <- QueryBuilder(query.list)

x <- as.integer(difftime(max(as.Date(query.list$end.date, '%Y-%m-%d')) , 
min(as.Date(query.list$start.date, '%Y-%m-%d')) , units = "days"))
# Daywise split paramter defaults to False when date does not equal Monday
daywisesplit <- if(x == 0) {
  F
}   else {
  T
}
# Extract the data and store it in a data-frame
example_camp <- GetReportData(ga.query, token, split_daywise = daywisesplit)
example_camp$date <- as.Date(example_camp$date, '%Y%m%d')
example_camp$brand <- 'Example'
example_camp <- subset(example_camp, sessions > 0)
example_camp <- subset(example_camp, adwordsCampaign > 0)

脚本运行时没有错误,但在查看write.csv文件时,我继续在AdwordsCampaignID列中看到(未设置)。此外,当我查看会话列时,不包括所有具有零会话的列,因此此过滤器正常工作。

如何在将数据提取到write.CSV时使排除(未设置)过滤器正常工作?也许我需要更新数据框?

0 个答案:

没有答案