R - Google Analytics Package [closed] - r

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Is there an R package that connects to the Google Analytics API? Does anyone have any pointers otherwise?

http://code.google.com/p/r-google-analytics/
This package is now available

Well, there's one option (that i am aware of) for explicitly connecting the two (Google Analytics & R).
This option requires R-DCOM (an interface to COM and DCOM to access R); you can get that here.
So i guess this is limited to Windows/.NET and C# (or any .NET language, i suppose).
I haven't used it (incompatible OS) but i have set it up for someone else; at least install & set-up are fairly straightforward:
install DCOM
then config--begin by executing the
"dcomcnfg" in the console window
this launches a component mgr; search
StatConnectorSrv in DCOM components
for 'properties'
update the permissions--done.
There's a also complete tutorial, source code included (C#), for DCOM setup/install and building a small App that has programmatic access to Google Analytics and R, available here.
But if all you want to do is get the data into R, all the pieces you need are readily available, e.g., my workflow:
export the data i need from the GA
main panel. GA delivers your data in
XML.
parse the raw data using the XML library (not part of the base distro, but available on CRAN)
(also pretty obvious) i store my
data in an R dataframe (for analysis
only, later it's broken up into
tables and stored in a PostgreSQL
database, using the RPostgreSQL
package, which provides the drivers
and R interface (DBI) to the pg
database).
Lastly, it's not GA but another Google data resource with an R interface: the Omega Project has a fairly new R Package that provides an interface to GoogleTrends (called 'RGoogleTrends'), available here.

I've put an updated version of the original r-google-analytics package on github: https://github.com/JerryWho/rgoogleanalytics
Here I've changed to version 2.4 of the API. The older version just used v2.3 which doesn't work since summer any more.

I'm actually building one now, i'll aim to get it onto CRAN as soon as possible

A new package has just been announced:
http://github.com/sorenmacbeth/googleanalytics4r

The Google Analytics API site has an example on how to retrieve analytics data using curl http://code.google.com/intl/fi-FI/apis/analytics/docs/gdata/2.0/gdataProtocol.html so supposedly you should be able to modify the examples and use Rcurl to retrieve the data.
There is a nice python package for getting data from GA that might give you some hints: http://github.com/clintecker/python-googleanalytics

There is a recently released R library on CRAN that enables Google Analytics Data extraction into R. It supports Google Analytics Core Reporting API v3 and uses OAuth2.0 under the hood for Authorization. You may be able to install the library via
install.packages("RGoogleAnalytics")
Or in case if you want the development version from Github you can try
require(devtools)
devtools::install_github("Tatvic/RGoogleAnalytics")

It would be fairly simple to create a wrapper using the RCurl and XML packages (very similar to the nytR or RGoogleDocs packages).

Just to give an update, i've now created the base script, which currently does the following:
Create a new export object.
Authenticate with your Google Account.
Return an account profile for an authorised Google Account.
Create a new API query
Use the query to return a data.frame populated with metrics.
I've also built in some low level error handling of the parameter types, but on some of the more complex parameters like segment, i've left the errors to the GA API.
I just need to build out the unit tests and package this up, and we should be good to go.
Mike

I've found another R-package for Google Anayltics: http://skardhamar.github.com/rga/
It uses OAuth2 for authentication.
I haven't tried it yet. But maybe that's the newest package out there.

There seems to be another Google Analytics-R package:
https://github.com/jdeboer/ganalytics/blob/master/README.md
I haven't tried it yet.

Related

How do I deploy an R code model in Salesforce Einstein Analytics Plus? Or find another alternative to Shiny?

tl;dr I want to deploy "live" model results in Python and R, and while Salesforce Einstein advertises this functionality for R and Python, I have only found support for Python. Shiny is too expensive to justify for our limited R-language requirements. Does Einstein R support actually exist?
UPDATE: Tableau has a separate solution from Einstein Analytics that hosts both R and Python - see answer below. Not a feature-rich direct competitor to Shiny, but that's not our use-case.
According to the documentation for Salesforce Einstein Analytics Plus (aka Tableau CRM AI Analytics), data scientists can upload (operationalize) their Python, R, and Matlab code, as described here:
https://www.tableau.com/solutions/ai-analytics (see the section on "Data Science" at the bottom of the page).
I signed up for a trial of Einstein Analytics Plus, and found a link to the "Model Manager." Using Model Manager to deploy Python-language models is well-documented here:
https://help.salesforce.com/s/articleView?id=sf.bi_edd_model_upload_prepare.htm&type=5
For Python, this seems to match the advertised functionality. But there is no indication of how to deploy R language models, which may be part of my team's use case.
I would like to find the equivalent method for deploying an R-language model in Einstein. Particularly, is there some other Salesforce / Tableau product I should try, or is this a feature that is simply not available in the trial version. Unlike Python deployment, searching the documentation has not yielded answers.
Alternatively, we're only interested in Einstein R support is because it appears to be about 1/10 the cost of Shiny, which is hideously expensive. So any recommendations regarding lightweight alternatives to Shiny would also be helpful.
TIA for anyone who can shine a light on this problem.
ANSWER: There is actually a separate feature in Tableau that is different from Einstein Analytics which supports both R and Python, documentation here:
https://help.tableau.com/current/prep/en-us/prep_scripts.htm

RTools Big Data and Visual Studio

So, I'm working on a big data project which requires importing data into Visual Studio and using Microsoft's R packages, in particular, the RevoScaleR packages. So, this is all well and good. I've written my scripts. What I would like to do is set it up so an end-user (who doesn't know anything about programming or R) can enter a set of parameters/values into my predict() function and see the output on his/her screen through a web interface or GUI/similar.
Any suggestions?
Thanks.
You can achieve this by leveraging Microsoft R Server's Operationalization Features, as this is a general question, please see the guides here:
https://msdn.microsoft.com/en-us/microsoft-r/operationalize/quickstart-publish-web-service

web based interpreter for language R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for a web based interpreter for the language R.
To be more precise , i am looking for a IDE like http://codepad.org/ where i can provide the code and the server should execute and provide me with the output.
I went through applications like Rapache but then they don't fit my requirement as they are not made to accept code from client , execute it and provide the result.
In short , i could find web application which takes input from the user , execute a specific R script and then place the output in a neatly formated way but not a web application which accepts R code ,execute it and then place it in a neat way.
A few possibilities come to mind:
ideone provides a lot of different languages, of which, R is one of them. When you run a script, you are provided with a link that you can embed in a webpage (but which doesn't show the output, unfortunately). If you create an account, you can also store your previously run scripts.
Pro: You can easily insert /plain/ into your script and be able to get a URL that can be sourced directly in R. For example, if the URL for your script online is "http://ideone.com/PIkeD", then you can use source("http://ideone.com/plain/PIkeD") to load your script directly from the ideone servers.
Cons: Stuck at version 2.11 Might not always be the most current version of R. Presently at 3.2.2. Can't install other packages. Output doesn't show in the embed script provided.
Cloudstat console runs a more recent version of R (2.15.1) with quite a few commonly used package. It used to have a really interesting blog/notebook interface that integrated code and the output, but that doesn't seem to be available at the moment.
Pro: Useful for running something fairly straightforward in a pinch.
Cons: Can't install other packages. Output is not formatted in code blocks, so is not easily readable. At the moment, can't save or share the code you've run.
Crunch offers a full RStudio setup, runs the most recent version of R, and allows you to install the packages you need. This may be more convenient than having to install your own RStudio server. You do have to request an account though.
Pros: Pretty much all you would expect from R/RStudio. Allows you to use Sweave and R markdown to automatically create documents too. These documents can be publicly hosted too. Here's an example where I've placed a page in a public folder called "gallery": http://crunch.kmi.open.ac.uk/people/~mrdwab/gallery/howzat.html
Cons: Sometimes the loading time is a bit slow, but as I am running RStudio desktop, I don't know how Crunch compares to running my own RStudio server.
Updated January 10, 2014
Recently, there has also been a decent amount of buzz around R-Fiddle as an interesting way to share R code. It looks like it is what powers the awesome http://www.rdocumentation.org/ site.
RStudio IDE (Server) may be the answer to your question. Have a look at http://www.rstudio.com/ide/
You can try Rcloud which we are developing in AT&T research lab. Its a open source IDE like Rstudio/IPYthon and has more advanced capabilities in terms of collaboration.
https://github.com/att/rcloud
RCloud is an environment for collaboratively creating and sharing data analysis scripts. RCloud lets you mix analysis code in R, HTML5, Markdown, Python, and others. Much like Sage, iPython notebooks and Mathematica, RCloud provides a notebook interface that lets you easily record a session and annotate it with text, equations, and supporting images.

Consume a web service in R

Here's the scenario:
I have JBoss serving a web service with JBossWS providing me with a wsdl. I have connected and used it from both .NET and Java so far (and it has been quite easy once I figured it out). I am now trying to do the same with R.
Is there anything out there considered to be "the right way" for doing this? I am not that familiar with R, and my searches have not turned up much, so I figured I'd ask and maybe spare my head and the wall a bit of damage.
I have had good luck using rJava to recreate in R something that works in Java. I use this method for connecting to Amazon's AWS Java SDK for their API with R. This allows me, for example, to transfer files to/from S3 from R without having to recreate the whole connection/handshake/boogieWoogie from R.
If you wanted to go more "pure R" I think you'll have to use some combination of RCurl and the XML package to grab and parse the wsdl.
There are a number of ways:
You could retain your Java approach and use the rJava package around it
You could use RCurl which is used to power a few higher-level packages (accessing Google APIs, say)
I believe there is an older SSOAP package on Omegahat which may help too.

Document/Scripts management for R code

I am looking for a solution that allows me to keep a track of a multitude of R scripts that I create for various projects and purposes. Some scripts are easily tracked to specific projects, whereas others are "convenience" functions created to serve a set of tasks.
Is there a way I can create a central DB and query it to find which scripts match most appropriately?
I could create a system using a DBMS manually, but are users aware of anything in general or specific to R, that comes in the form of a software tool (maybe FOSS) ?
EDIT: Thank you for the responses. My current system is just a set of scripts with comments that allow me to identify their intended task. Though I use StatET with SVN, I would like a search utility along the lines of the "sos" package.
The question
I am looking for a solution that allows me to keep a track of a multitude of R scripts
that I create for various projects and purposes. Some scripts are easily tracked to specific
projects, whereas others are "convenience" functions created to serve a set of tasks.
fails to address the obvious follow-up of why the existing mechanism is not suitable:
Create a local package for each project
Create one or more local packages for local utility functions
Use R's already existing mechanisms for searching, indexing, testing, cross-referencing
And use any revision control system of your liking, local or on the web, to host the code for 1. to 3. above.
Reinventing an RDBMS schema for 1. to 3. is just wrong in my book. But if you must, go ahead and replicate what you can already (mostly) get for free in tested and widely used code.
R comes with several mechanisms for searching for help, most of which naturally use CRAN. Some examples: the sos package, cranberries, crantastic, and rseek. In many cases, these could be adapted to use a local repository (you can find out how to create a local repository in the R manual, which is very easy to do). Otherwise, if you package your scripts and submit them to CRAN, you will naturally have these available to you. I would also highly recommend this presentation on the subject: Creating R Packages, Using CRAN, R-Forge, And Local R Archive Networks And Subversion (SVN) Repositories from Spencer Graves and Sundar Dorai-Raj.
These would require you to put your code in packages, and create documentation, all of which is worth doing anyway. The package documentation turns out to be very useful for both documenting what things do, and helping your find them in the future. You can use roxygen to create this documentation in-line with your code. Also read this related question: Organizing R Source Code.
Alternatively, the help.search() function can be very useful for searching local packages, regardless of whether you have a repository set up.
You'd probably be best working with a version control system. Many can be indexed and be made search-able. At my work, a stack of R, Eclipse, StatET, Subversion and Subclipse works very well for us.

Resources