artemklevtsov / RGA

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

Error in names(res$query) <- rename_params(names(res$query)) #24

Closed Ashkan33 closed 8 years ago

Ashkan33 commented 8 years ago

Hi, I get the error:

attempt to change an attribute to NULL

running this piece of code:

get_ga(id,
                       start.date = first.date,
                       end.date = last.date,
                       metrics = ga.metrics, 
                       dimensions = ga.dimensions,
                       samplingLevel = "HIGHER_PRECISION",
                       fetch.by = "month",
                       token = ga_token)

with:

ga.dimensions <- c("ga:channelGrouping",
                   "ga:deviceCategory",
                   "ga:pageDepth",
                   "ga:date",
                   "ga:daysSinceLastSession",
                   "ga:sessionDurationBucket",
                   "ga:userType")

ga.metrics <- c("ga:goal1Completions",
               "ga:goal2Completions",
               "ga:goal3Completions",
               "ga:goal4Completions",
               "ga:goal5Completions",
               "ga:goal6Completions",
               "ga:pageviews",
               "ga:bounces",
               "ga:sessions",
               "ga:users")

here is the traceback:

9: fetch_by(path, query, by, token)
8: get_report("data/ga", query, token, fetch.by)
7: get_ga(id, start.date = first.date, end.date = last.date, metrics = ga.metrics, 
       dimensions = ga.dimensions, samplingLevel = "HIGHER_PRECISION", 
       fetch.by = "month", token = ga_token)
6: force(expr)
5: with_config(verbose(...), expr)
4: httr::with_verbose(get_ga(id, start.date = first.date, end.date = last.date, 
       metrics = ga.metrics, dimensions = ga.dimensions, samplingLevel = "HIGHER_PRECISION", 
       fetch.by = "month", token = ga_token)) at #35
3: FUN(X[[i]], ...)
2: lapply(properties.data$id, function(id) {
       first.date <- firstdate(id)
       first.date <- "2013-01-01"
       last.date <- "2016-02-29"
       if (id == "33529605" & as.POSIXct(last.date) < "2015-12-15") {
           message("Nessun dato da scaricare dal vecchio hotpoint.uk")
           return(NULL)
       }
       if (id == "33529605" & as.POSIXct(last.date) > "2015-12-15") {
           last.date <- "2015-12-15"
       }
       if (id == "104307347" & as.POSIXct(first.date) < "2015-12-16") {
           message("Forza inizio dati al primo giorno di dati del nuovo hotpoint.uk")
           first.data <- "2015-12-16"
       }
       if (id == "104307347" & as.POSIXct(last.date) < "2015-12-16") {
           message("Nessun dato da scaricare dal nuovo hotpoint.uk")
           return(NULL)
       }
       message(paste(id, " - from=", as.character(first.date), "; to=", 
           last.date, sep = ""))
       df = httr::with_verbose(get_ga(id, start.date = first.date, 
           end.date = last.date, metrics = ga.metrics, dimensions = ga.dimensions, 
           samplingLevel = "HIGHER_PRECISION", fetch.by = "month", 
           token = ga_token))
       df$id <- id
       return(df)
   })
1: do.call(rbind.fill, lapply(properties.data$id, function(id) {
       first.date <- firstdate(id)
       first.date <- "2013-01-01"
       last.date <- "2016-02-29"
       if (id == "33529605" & as.POSIXct(last.date) < "2015-12-15") {
           message("Nessun dato da scaricare dal vecchio hotpoint.uk")
           return(NULL)
       }
       if (id == "33529605" & as.POSIXct(last.date) > "2015-12-15") {
           last.date <- "2015-12-15"
       }
       if (id == "104307347" & as.POSIXct(first.date) < "2015-12-16") {
           message("Forza inizio dati al primo giorno di dati del nuovo hotpoint.uk")
           first.data <- "2015-12-16"
       }
       if (id == "104307347" & as.POSIXct(last.date) < "2015-12-16") {
           message("Nessun dato da scaricare dal nuovo hotpoint.uk")
           return(NULL)
       }
       message(paste(id, " - from=", as.character(first.date), "; to=", 
           last.date, sep = ""))
       df = httr::with_verbose(get_ga(id, start.date = first.date, 
           end.date = last.date, metrics = ga.metrics, dimensions = ga.dimensions, 
           samplingLevel = "HIGHER_PRECISION", fetch.by = "month", 
           token = ga_token))
       df$id <- id
       return(df)
   }))

Here is the session Info:

R version 3.2.2 (2015-08-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

locale:
 [1] LC_CTYPE=it_IT.UTF-8          LC_NUMERIC=C                  LC_TIME=it_IT.UTF-8          
 [4] LC_COLLATE=it_IT.UTF-8        LC_MONETARY=it_IT.UTF-8       LC_MESSAGES=it_IT.UTF-8      
 [7] LC_PAPER=it_IT.UTF-8          LC_NAME=it_IT.UTF-8           LC_ADDRESS=it_IT.UTF-8       
[10] LC_TELEPHONE=it_IT.UTF-8      LC_MEASUREMENT=it_IT.UTF-8    LC_IDENTIFICATION=it_IT.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] RGA_0.4.1         markdown_0.7.7    knitr_1.12.3      hwriter_1.3.2     mailR_0.4.1      
 [6] stringr_1.0.0     plyr_1.8.3        facebook.S4_1.0.0 RMySQL_0.10.8     DBI_0.3.1        

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.3       lubridate_1.5.0   R.methodsS3_1.7.1 R6_2.1.2          jsonlite_0.9.19  
 [6] magrittr_1.5      httr_1.1.0        stringi_1.0-1     curl_0.9.6        R.oo_1.20.0      
[11] R.utils_2.2.0     rjson_0.2.15      tools_3.2.2       rJava_0.9-8       openssl_0.9.2
artemklevtsov commented 8 years ago

Duplicate #23.

artemklevtsov commented 8 years ago

Please try the latest git-version.

Ashkan33 commented 8 years ago

Oops! Sorry and thanks! Another thing, from time to time, I get the time-out and sever connection error. What's that and how can it be solved?

artemklevtsov commented 8 years ago

You should provide a more information and describe it in other issues.