0

I'm using RGoogleAnalytics, I'm just at the learning stage at the moment.

I'm following the code in the tutorial here https://code.google.com/p/r-google-analytics/

But when I try to run

ga.goals <- conf$GetGoals()
ga.goals

I get an error message telling me there is an unexpected escaped character '\.' at pos 7

I get a similar message for the next two lines of code (GetSegments)

This question deals with a similar problems in the Facebook Graphs API

How to replace "unexpected escaped character" in R

I've tried using a similar bit of code

confGoalsSub <- gsub('\\.', ' ', conf$GetGoals())

to remove the escaped characters, but I get another error :

cannot coerce type 'closure' to vector of type 'character'

Out of desperation I have tried confGoalsSub <- gsub('\\.', ' ', conf) which returns a character vector that is just garbage (it's just the code for conf with the decimal points stripped out).

Can anyone suggest a better expression than gsub that will return a useful object?

EDIT: As per the suggestion below I've now added the brackets at the end of the function call but I still get the same error message about unexpected escape characters. I get the same error when I try to call other, similar function such as $GetSegments().

I saw on one video at the weekend that this package was broken for a long time, although the speaker did not provide details as to why. Perhaps I should give up and try one of the other Google Analytics packages in R.

Seems odd, given that this one is supposed to be Google supported.

Community
  • 1
  • 1
Simon Hayward
  • 694
  • 11
  • 26
  • 1
    I didn't install the package or anything, but from the code you've shown, `conf$GetGoals` appears to be a function. Did you mean `gsub('\\.', ' ', conf$GetGoals())` (note the `()`) – GSee Oct 04 '13 at 15:38
  • Sadly I've left work and can't check, but that looks highly plausible. Embarrassing. – Simon Hayward Oct 04 '13 at 21:48
  • Have now edited this to reflect that the suggestion was correct, but did not fix the problem. – Simon Hayward Oct 07 '13 at 15:38

1 Answers1

1

I think this error arises when the RJSON library isn't able to parse the Google Analytics Data Feed properly and convert it into a nested list. The updated version of [RGoogleAnalytics] (http://cran.r-project.org/web/packages/RGoogleAnalytics/index.html) fixes this problem. Currently, you won't be able to retrieve Goals and Segments from your Google Analytics account using the library but beyond that it supports the full range of dimensions and metrics.

kushan_s
  • 313
  • 2
  • 6