artemklevtsov / RGA

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

Error getting data with get_ga - date "2015-10-18" comes as NA #32

Open diegocgaona opened 8 years ago

diegocgaona commented 8 years ago

Hi,

I get a weird error in more than one account.

With this query:

test <- get_ga(ids, start.date = last_year_s,
                                    end.date = currentdate-1,
                                    dimensions = "ga:date, ga:channelGrouping",
                                    metrics = "ga:users, ga:sessions, ga:pageviews, ga:percentNewSessions, ga:bounceRate",
                                    segment = "",
                                    max.results = 10000,
                                    samplingLevel = "HIGHER_PRECISION",
                                    include.empty.rows = "TRUE")

The column "date" come almost all correct, but the date "2015-10-18" comes as NA. The same error occurred with different accounts. I tried to use fetch.by, but get the same result.

Someone have any idea of the reason?

Thanks, Diego.

artemklevtsov commented 8 years ago

Now I can't to reproduce:

library(RGA)
authorize()
gadata <- get_ga(id, start.date = "2015-01-01", end.date = "today",
                 dimensions = "ga:date, ga:channelGrouping",
                 metrics = "ga:users, ga:sessions, ga:pageviews, ga:percentNewSessions, ga:bounceRate",
                 samplingLevel = "HIGHER_PRECISION", include.empty.rows = "TRUE")
anyNA(gadata)
#> [1] FALSE
diegocgaona commented 8 years ago

Hi @artemklevtsov,

Very weird, I tried 3 different websites... and the same result. Maybe is a problem with Analytics.

I tried your code, and my result is it: download

My version info:

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252    LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                       LC_TIME=Portuguese_Brazil.1252    

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

other attached packages:
[1] RGA_0.4.2           RevoUtilsMath_3.2.3

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.4         knitr_1.12.3        magrittr_1.5        bit_1.1-12          xtable_1.8-2        rjson_0.2.15       
 [7] R6_2.1.2            plyr_1.8.3          stringr_1.0.0       httr_1.1.0          tools_3.2.3         DT_0.1             
[13] DBI_0.4             htmltools_0.3.5     openssl_0.9.2       bit64_0.9-5         digest_0.6.9        shiny_0.13.2       
[19] twitteR_1.1.9       htmlwidgets_0.6     curl_0.9.7          rsconnect_0.4.3     mime_0.4            stringi_1.0-1      
[25] lubridate_1.5.6     jsonlite_0.9.19     formattable_0.1.7.1 httpuv_1.3.3        markdown_0.7.7 
artemklevtsov commented 8 years ago

Can you test it on the different machine?

acvelozo commented 6 years ago

Hi,

First of all, thank you @artemklevtsov for this great package, it's a real time saver in my daily work! I am encountering the same issue as described above by @diegocgaona .

In my case, this issue is occuring for the following dates:

Here is a sample query that shows this error for the date "2017-10-15":

require(RGA)
authorize(username = "XXX", client.id = "XXX", client.secret = "XXX")
GA_Data <- get_ga(
        profileId  = XXXXXXXXX,
        dimensions = c('ga:date','ga:year','ga:month','ga:day'),
        metrics    = 'ga:goal2Completions',
        start.date =  '2017-10-13',
        end.date   =  '2017-10-17')

And here is what the result looks like:

> print(GA_Data)

        date year month day goal2Completions
1 2017-10-13 2017    10  13                0
2 2017-10-14 2017    10  14                0
3       <NA> 2017    10  15                0
4 2017-10-16 2017    10  16                0
5 2017-10-17 2017    10  17                0

This error doesn't happen when I use the Excel add-in AnalyticsEdge to get the same information from the Core Analytics API,

This error only happens in one of my accounts and doesn't occur for all the views. I don't know if this is a relevant info, but the views that have this problem are all in the timezone of "Sao Paulo - Brazil".

Here is my session info:

R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252  LC_CTYPE=Portuguese_Portugal.1252    LC_MONETARY=Portuguese_Portugal.1252
[4] LC_NUMERIC=C                         LC_TIME=Portuguese_Portugal.1252    

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

other attached packages:
[1] RGA_0.4.2

loaded via a namespace (and not attached):
 [1] httr_1.3.1      compiler_3.4.2  plyr_1.8.4      magrittr_1.5    R6_2.2.2        tools_3.4.2     curl_3.0        yaml_2.1.14     Rcpp_0.12.13   
[10] lubridate_1.6.0 stringi_1.1.5   stringr_1.2.0   jsonlite_1.5    httpuv_1.3.5    openssl_0.9.7

Thanks in advance for any insights on this issue! Best regards