How to install openWAR R package in RStudio in Ubuntu 14.04 LTS

Posted: 2014/07/16 in Data Science, Ubuntu
Tags: , , , , ,

####################################################################

# how to install openWAR R package in Ubuntu 14.04 LTS

####################################################################
        
        # in Ubuntu 14.04 LTS, first run this Terminal command to install prerequisites:
        # sudo apt-get install libxml2-dev libxslt1-dev libcurl4-gnutls-dev
        # then run the following commands in RStudio:
        install.packages(“devtools”)
        library(devtools)
        install.packages(“stringr”)
        library(stringr)
        install.packages(“plyr”)
        library(plyr)
        install.packages(“RCurl”)
        library(RCurl)
        install.packages(“bitops”)
        library(bitops)
        # install Sxslt via the following forked github repository:
        install_github(“Sxslt”, “cboettig”)
        install_github(“openWAR”, “beanumber”)
        library(openWAR)
        gd = gameday()
        summary(gd)
        # following command will retrieve data from 15 games from yesterday:
        ds = getData()
        head(ds)
        summary(ds)
        str(ds)
    
    
    Here is the output I got on my computer running Ubuntu 14.04 LTS:
    
    > library(devtools)
    > install_github(“openWAR”, “beanumber”)
    Installing github repo openWAR/master from beanumber
    Downloading master.zip from https://github.com/beanumber/openWAR/archive/master.zip
    Installing package from /tmp/RtmpQjDf5N/master.zip
    arguments ‘minimized’ and ‘invisible’ are for Windows only
    Installing openWAR
    ‘/usr/lib/R/bin/R’ –vanilla CMD build ‘/tmp/RtmpQjDf5N/devtools4acb2bc694ba/openWAR-master’ –no-manual –no-resave-data
    
    * checking for file ‘/tmp/RtmpQjDf5N/devtools4acb2bc694ba/openWAR-master/DESCRIPTION’ … OK
    * preparing ‘openWAR’:
    * checking DESCRIPTION meta-information … OK
    * installing the package to build vignettes
    * creating vignettes … OK
    * excluding invalid files
    Subdirectory ‘demo’ contains invalid file names:
      ‘Ben.Rmd’ ‘Ben.html’ ‘analysis.Rmd’ ‘sanity_checks.Rmd’
    * checking for LF line-endings in source and make files
    * checking for empty or unneeded directories
    * looking to see if a ‘data/datalist’ file should be added
    Warning in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
      EOF within quoted string
    * building ‘openWAR_0.1-1.tar.gz’
    
    ‘/usr/lib/R/bin/R’ –vanilla CMD INSTALL ‘/tmp/RtmpQjDf5N/openWAR_0.1-1.tar.gz’ –library=’/home/ulysses/R/x86_64-pc-linux-gnu-library/3.1′  \
      –install-tests
    
    * installing *source* package ‘openWAR’ …
    ** R
    ** data
    ** demo
    ** inst
    ** preparing package for lazy loading
    Warning: replacing previous import by ‘plyr::count’ when loading ‘openWAR’
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    Warning: replacing previous import by ‘plyr::count’ when loading ‘openWAR’
    * DONE (openWAR)
    > gd = gameday()
    Error: could not find function “gameday”
    > library(openWAR)
    Warning message:
    replacing previous import by ‘plyr::count’ when loading ‘openWAR’
    > gd = gameday()
    gid_2012_08_12_atlmlb_nynmlb_1
    Loading required package: Sxslt
    Loading required package: stringr
    Loading required package: plyr
    > summary(gd)
           Length Class      Mode     
    gameId  1     -none-     character
    base    1     -none-     character
    url     5     -none-     character
    ds     62     data.frame list     
    > ds = getData()
    Loading required package: RCurl
    Loading required package: bitops
    
    Retrieving data from 2014-07-12 …
    …found 15 games
    gid_2014_07_12_anamlb_texmlb_1
    gid_2014_07_12_arimlb_sfnmlb_1
    gid_2014_07_12_atlmlb_chnmlb_1
    gid_2014_07_12_bosmlb_houmlb_1
    gid_2014_07_12_chamlb_clemlb_1
    gid_2014_07_12_detmlb_kcamlb_1
    gid_2014_07_12_miamlb_nynmlb_1
    gid_2014_07_12_minmlb_colmlb_1
    gid_2014_07_12_nyamlb_balmlb_1
    gid_2014_07_12_oakmlb_seamlb_1
    gid_2014_07_12_pitmlb_cinmlb_1
    gid_2014_07_12_sdnmlb_lanmlb_1
    gid_2014_07_12_slnmlb_milmlb_1
    gid_2014_07_12_tormlb_tbamlb_1
    gid_2014_07_12_wasmlb_phimlb_1
    Warning messages:
    1: In readData.gameday(gd) : NAs introduced by coercion
    2: In readData.gameday(gd) : NAs introduced by coercion
    3: In readData.gameday(gd) : NAs introduced by coercion
    4: In readData.gameday(gd) : NAs introduced by coercion
    5: In readData.gameday(gd) : NAs introduced by coercion
    6: In readData.gameday(gd) : NAs introduced by coercion
    7: In readData.gameday(gd) : NAs introduced by coercion
    > head(ds)
      pitcherId batterId field_teamId ab_num inning   half balls strikes endOuts     event actionId
    6    571945   594777          140      1      1    top     1       0       1    Flyout       NA
    7    571945   545361          140      2      1    top     1       1       2   Lineout       NA
    8    571945   405395          140      3      1    top     1       2       3 Groundout       NA
    1    450308   425783          108      4      1 bottom     4       2       0      Walk       NA
    2    450308   462101          108      5      1 bottom     0       1       0  Sac Bunt       NA
    3    450308   425567          108      6      1 bottom     0       1       1  Forceout       NA

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s