0
(0)
[統計] Google Analytics For The R 導入方法(途中


R https://www.fxfrog.com/?p=1932 (R 32bit) / https://www.fxfrog.com/?p=1908 (R64bit) R-GoogleAnalytics  http://code.google.com/p/r-google-analytics/ 

 Google API 

Windows

R使

Package: RGoogleAnalytics
Title: R Handler for importing Google Analytics information from the
Google Analytics API
Version: 1.1
Date: 2010-10-11

===

 R-GoogleAnalytics  RGui > 

> install.packages(RCurl, repos = http://www.omegahat.org/R)
downloaded 2.6 Mb

> install.packages(XML, repos = http://www.omegahat.org/R)
 downloaded 3.4 Mb

R-GoogleAnalytics 

http://r-google-analytics.googlecode.com/files/RGoogleAnalytics_1.1.tar.gz RGUI 

> install.packages(http://r-google-analytics.googlecode.com/files/RGoogleAnalytics_1.1.tar.gz,repos=NULL,type=source)

RGoogleAnalytics_1.1.tar.gz  > 

> install.packages(C:UsersyukioDesktopRGoogleAnalytics_1.1.tar.gz,repos=NULL,type=source)

 C:UsersyukioDocuments/R/win-library/2.12 
(lib )
* installing *source* package RGoogleAnalytics 
** R
** inst
** preparing package for lazy loading
Loading required package: bitops
** help
*** installing help indices
** building package indices 
** testing if installed package can be loaded

* DONE (RGoogleAnalytics)
>

問題なく導入可能でした。念のためパッケージ(ライブラリ)参照状況を確認しましょう。






RGoogleAnalytics 

===





> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})

 : RGoogleAnalytics

The following object(s) are masked _by_ .GlobalEnv:

    QueryBuilder, RGoogleAnalytics

> ga <- RGoogleAnalytics()
> ga$SetCredentials(GA,GA)



  postForm(https://www.google.com/accounts/ClientLogin, Email = username,  :
  SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

CA

RGoogleAnalytics.R QueryBuilder.R  RCurl getURL RCurl  https://www.google.com/  SSL RCurl FAQ

getURLContent(https://www.google.com, ssl.verifypeer = FALSE) 


http://ademar.name/blog/2006/04/curl-ssl-certificate-problem-v.html 

RGUI IEhttp proxy DLL IECApem  RGoogleAnalytics.R 1

pem 

C:UsersyukioDocumentsRwin-library2.12RCurlCurlSSL 

 cacert.pem  google.com  https  RGui 

> x = getURLContent(https://www.google.com,cainfo = C:\Users\yukio\Desktop\cacert.pem)

ga 


2

RGoogleAnalytics.R  GoogleAPI 14APIAPI



  SetCredentials <- function(username, pass) {
    # Authorizes this script to access the users Google Analytics Account.
    # Passes the username and password to the Google Accounts API ClientLogin
    # routine to get an authorization token which can be used to access
    # the users Google Analytics data. This token is stored in the auth.token
    # private member and stays valid for 14 days. The token can later be used
    # with queries to the Google Analytics API. Note: We do not store the
    # username or password for security reasons.
    #
    # Args:
    #   username: A valid user name for a Google Analytics account.
    #   pass: A valid password for the Google Analytics account.
    # Returns:
    #   Returns the authorization token of the users account.

    # Error handling.
    # Ensure that both user name and password have been entered.
    if (is.null(username) || is.null(pass)) {
      stop(Please supply a user name and password)
    }

    auth.resp <- postForm(https://www.google.com/accounts/ClientLogin,
                          Email = username,
                          Passwd = pass,
                          accountType = GOOGLE,
                          source = r-google-analytics,
                          service = analytics)
    gtoken <- unlist(strsplit(auth.resp, n))
    parsed.gtoken <- unlist(strsplit(gtoken[3], Auth=))
    if (length(parsed.gtoken) >= 2) {
      auth.token <<- unlist(strsplit(gtoken[3], Auth=))[[2]]
    } else {
      stop(Authentication failed.)
    }

    return(invisible())
  }

 API 




How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

投稿者 斉藤之雄 (Yukio Saito)

Global Information and Communication Technology OTAKU / Sports volunteer / Social Services / Master of Technology in Innovation for Design and Engineering, AIIT / BA, Social Welfare, NFU / twitter@yukio_saitoh

コメントは受け付けていません。