Skip to content

Modifying output to Google Docs

9 messages · Barry Rowlingson, Jim Lemon, Duncan Temple Lang +1 more

#
2008/9/23 Ajay ohri <ohri2007 at gmail.com>:
Do you basically mean an R implementation of the Google Data APIs:

http://code.google.com/apis/gdata/clientlibs.html

 or at least, that part of the API for dealing with google documents?

http://code.google.com/apis/documents/developers_guide_protocol.html

 That would be very interesting... something like:

 library(google)
 g=google("username","password")
 d=data.frame(x=1:10,y=runif(10))
 googleSendData(g, d)

 it might be easier to start by hooking into one of the other language
client libs (java, python) instead of trying to write one in native R
from the start. Although there's XML handling for R and the protocol
appears to be based on that....

 Something to do in those long winter nights ahead in the northern
hemisphere perhaps...

Barry
#
2008/9/23 Ajay ohri <ohri2007 at gmail.com>:
There's command-line tools (written in python, but probably in other
languages elsewhere) to do this:

http://code.google.com/p/gdatacopier/

 their example is:

./gdoc-cp.py --username someone at gmail.com --import --local
files/doc.txt --title "New Document"

 So all you need to do is call that from R with system() and wrap it
up in some R functions.

Barry
#
Ajay ohri wrote:
Hi Ajay,
Do you mean transforming R output into HTML? The R2HTML package does 
this, and the htmlize and R2html functions in the prettyR package do so 
as well.

Jim
#
The command line app is fine, although there are some potential security
issues or annoyances with a smooth work flow.

But it would be more flexible and powerful to do it directly in R.
And we don't need to know or program in C. The RCurl (https, getForm() 
and postForm()) and XML packages provide all we need.

It took a couple of hours of reading the Google documentation,
designing and writing the R code and _testing_, but in relatively
few lines of code, the RGoogleDocs "package" enables an R user
to query, delete, download and upload documents to her Google account.
This was one of the motivations for developing the XML and RCurl 
packages, i.e. to be able to quickly develop utilities in R to
communicate with Web "apps".  So Ajay's suggestion was a nice
exercise to see if the packages do make it easy.

The package currently has no Rd files, but there is a brief "user's 
guide". The package is available from
         http://www.omegahat.org/RGoogleDocs

For binary files, you will want to grab a beta-version of RCurl
at http://www.omegahat.org/Prerelease/RCurl_0.91-0.tar.gz

  D.
Barry Rowlingson wrote: