artemklevtsov / RGA

A Google Analytics API client for R
http://cran.r-project.org/package=RGA
32 stars 13 forks source link

vapply error when using fetch.by = day and ga:sessionDuration #45

Open lcormaw opened 7 years ago

lcormaw commented 7 years ago

Hi,

When using a fetch.by = day, here is the error and traceback:

Error in vapply(x, function(x) as.numeric(x[[name]]), numeric(1)) : 
  values must be length 1,
but FUN(X[[1]]) result is length 0
> traceback()
5: vapply(x, function(x) as.numeric(x[[name]]), numeric(1))
4: sum_by(pages, "sampleSize")
3: fetch_by(path, query, by, token)
2: get_report("data/ga", query, token, fetch.by)

The query was:

get_ga(profileId = ga_id,
            start.date = "2016-01-01",
            end.date = "2016-11-01",
            metrics = "ga:sessions,ga:bounces,ga:sessionDuration,ga:pageviews,ga:goal7Completions,ga:goal17Completions,ga:goal18Completions",
            dimensions = "ga:date,ga:yearMonth,ga:landingPagePath,ga:dcmClickSitePlacement,ga:dcmClickCampaign,ga:dcmClickSite",
            filters = "ga:dcmClickCampaign=~xxxxxxxx",
            fetch.by = "day"
)

After playing with the date range, it appears to be caused by the absence of data returned for one day (where the filter does not match anything). Is there any workaround to this without having to find the problematic date manually?

Thanks for your help!