artemklevtsov / RGA

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

Error in vapply in fetch.by = week #27

Closed MarekLu closed 8 years ago

MarekLu commented 8 years ago

When I use fetch.by = "week" in my query, the result is always:

Error in vapply(x, function(x) x[[name]], numeric(1)) : 
  values must be type 'double',
 but FUN(X[[1]]) result is type 'character'

But when I use fetch.by = "day", everything is all right, so the week parameter could be the source of this issue. My query looks like this:

get_ga(
    profileId  = "xxxxxxx",
    start.date = "2016-03-01",
    end.date   = "2016-03-19",
    metrics    = "ga:pageviews",
    dimensions = "ga:year,ga:week",
    filter     = "ga:landingPagePath==xxxxxx;ga:source==(direct)",
   fetch.by   = "week")
artemklevtsov commented 8 years ago

Do you try a git-version? It should be fixed with 95d487b3bb7f8004e76dfab9d3efca61809921bc.

MarekLu commented 8 years ago

Thank you, the git-version works.

MarekLu commented 8 years ago

Hi, I have very similar query again, I use git-version of RGA and I get new error:

Error in vapply(x, function(x) as.numeric(x[[name]]), numeric(1)) : 
  values must be length 1, but FUN(X[[18]]) result is length 0

My code:

get_ga(
  profileId = "xxxx",
  start.date = "2016-03-01",
  end.date = "2016-04-16",
  dimensions = "ga:yearWeek",
  metrics = "ga:sessions,ga:pageviews",
  filters = "ga:source==xxxxx,ga:landingPagePath==xxxxxx",
  fetch.by = "week")

If I set start.date 2016-04-01, it works. With 2016-03-01 not.

MarekLu commented 8 years ago

Thank you, it works now.

Ashwin611 commented 5 years ago

Hi, When I use this query to get android data(profileID) it works fine for fetch.by="week" parameter. but I get an error while using fetch.by="day"

"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"

I get the same error while retrieving iOS data or Website data. A similar error is encountered if I use more than 150 filters in OR condition at a time.

If this error means I should try to get fewer data why does it work well for android but not for iOS, (given the android data is much more than iOS data.)

dimension1 <- "ga:productSku==17186,ga:productSku==16381"

(but 150 such productIDs)

This works fine

app_city_android <- get_ga(profileId = "ga:**(ID_for_Android)", start.date = start_date_char, end.date = end_date_char, metrics = "ga:users", dimensions = "ga:sourceMedium,ga:dimension1", sort = NULL, filters = propertyID1, segment = NULL, samplingLevel ="HIGHER_PRECISION", start.index = NULL, max.results = NULL, include.empty.rows = NULL, fetch.by = "week", token = ga_token)

This gives an error

app_city_iOS <- get_ga(profileId = "*****(ID_for_iOS)", 
                       start.date = start_date_char,
                       end.date = end_date_char, 
                       metrics = "ga:users", 
                       dimensions = "ga:sourceMedium,ga:dimension1",
                       sort = NULL, 
                       filters = propertyID1,
                       segment = NULL,
                       samplingLevel =NULL,
                       start.index = NULL,
                       max.results = NULL, 
                       include.empty.rows = NULL, 
                       fetch.by = "week",
                       token = ga_token)

This too gives that error

app_city_android <- get_ga(profileId = "ga:**(ID_for_Android)", start.date = start_date_char, end.date = end_date_char, metrics = "ga:users", dimensions = "ga:sourceMedium,ga:dimension1", sort = NULL, filters = propertyID1, segment = NULL, samplingLevel ="HIGHER_PRECISION", start.index = NULL, max.results = NULL, include.empty.rows = NULL, fetch.by = "day", token = ga_token)