R language

February 20, 2018.

Notes and links on R.

Meta

Articles

Books and manuals

Tools

Learning R

Classes

Blogs

Packages

Code samples

Libraries

Tech notes, papers and articles on R

Installing R and contributed libraries.

R is made of r-core and thousands of contributed libraries. To begin with, we need to install the core application.

On Linux:

$ sudo apt-get install r-base-core

R and PostgreSQL

Preparing R to query data from postgresql. Reference.

Installation

$ sudo apt-get install libpq-dev
$ sudo apt-get install r-base-core
$ export PG_LIB_DIR=/usr/lib/postgresql/8.4/lib/
$ export PG_INCLUDE_DIR=/usr/include/postgresql

Install R packages from the bash/zsh shell

export CRAN_MIRROR="http://cran.case.edu/"
echo "install.packages(\"rjson\", repos=\"$CRAN_MIRROR\")" | R --vanilla

R Session

source("http://bioconductor.org/biocLite.R")
biocLite("RdbiPgSQL")
library(RdbiPgSQL)
conn <- dbConnect(PgSQL(), host="localhost", dbname="somedb", user="pradeep", password="secret")
res <- dbSendQuery(conn, "SELECT a,b,c from sometable")
mydata <- dbGetResult(res)