artemklevtsov / RGA

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

get_realtime function #4

Closed XD-DENG closed 8 years ago

XD-DENG commented 8 years ago

I tested function get_realtime with codes below

while (TRUE){
  print(print(get_realtime("*******")))
  Sys.sleep(3)
}

If there is no visitor currently on my website, this code returns

No results were obtained.
NULL
NULL

which makes sense (and the while loop keeps running well).

But once these is any visitor, I got error as

Error in `colnames<-`(`*tmp*`, value = character(0)) : 
  attempt to set 'colnames' on an object with less than two dimensions

I may look into this issue myself later and build a pull request after I figure it out (if I'm lucky enough ;-))

artemklevtsov commented 8 years ago

get_realtime(id) works fine for me with or without active users.

> while (TRUE){
+     print(get_realtime(id))
+     Sys.sleep(3)
+ }
  active.users
1          120
  active.users
1          121
  active.users
1          121

Do you try the latest dev version? Can you provide full traceback()?

XD-DENG commented 8 years ago

Hi Artem, below is the traceback I got.

Just like what happened previously, the error appeared when the site is visited (from "No visitor" status).

> library(RGA)
> while (TRUE){
+ print(get_realtime("******"))
+ Sys.sleep(3)
+ }
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
No results were obtained.
NULL
No results were obtained.
NULL
No results were obtained.
NULL
No results were obtained.
NULL
 Hide Traceback

 Rerun with Debug
 Error in `colnames<-`(`*tmp*`, value = character(0)) : 
  attempt to set 'colnames' on an object with less than two dimensions 
7 stop("attempt to set 'colnames' on an object with less than two dimensions") 
6 `colnames<-`(`*tmp*`, value = character(0)) 
5 build_df(type, data_json) 
4 get_data(type = type, query = query, token = token) 
3 get_report(type = "realtime", query = query, token = token) 
2 get_realtime("103394634") 
1 print(get_realtime("******")) 
artemklevtsov commented 8 years ago

What version are you using? Please try the dev version: devtools::install_github("artemklevtsov/RGA").

XD-DENG commented 8 years ago

I'm using latest version 0.2.4 on CRAN, with R 3.2.2 and Mac OS.

Let me try the dev version and check if this bug is still there. Will let you know then.

XD-DENG commented 8 years ago

Tried the dev version and the dev version works well for this function. Good job.

artemklevtsov commented 8 years ago

Thank you for the feedback.

GKyle23 commented 8 years ago

I had the same problem, but your dev version works nicely