Created
June 24, 2016 04:56
-
-
Save jvawdrey/70c7df122dca6bb01342ce7f63fec0fe to your computer and use it in GitHub Desktop.
R dependencies and Greenplum database connection example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# r-start.R | |
######################################################################################## | |
## Dependencies | |
######################################################################################## | |
# package:: RPostgreSQL | |
if("RPostgreSQL" %in% rownames(installed.packages()) == FALSE) | |
install.packages("RPostgreSQL") | |
library(RPostgreSQL) | |
# package:: randomForest | |
if("randomForest" %in% rownames(installed.packages()) == FALSE) | |
install.packages("randomForest") | |
library(randomForest) | |
# package:: rpart | |
if("rpart" %in% rownames(installed.packages()) == FALSE) | |
install.packages("rpart") | |
library(rpart) | |
# package:: pROC | |
if("pROC" %in% rownames(installed.packages()) == FALSE) | |
install.packages("pROC") | |
library(pROC) | |
# package:: ROCR | |
if("ROCR" %in% rownames(installed.packages()) == FALSE) | |
install.packages("ROCR") | |
library(ROCR) | |
# package:: e1071 | |
if("e1071" %in% rownames(installed.packages()) == FALSE) | |
install.packages("e1071") | |
library(e1071) | |
# package:: usdm | |
if("usdm" %in% rownames(installed.packages()) == FALSE) | |
install.packages("usdm") | |
library(usdm) | |
# package:: SDMTools | |
if("SDMTools" %in% rownames(installed.packages()) == FALSE) | |
install.packages("SDMTools") | |
library(SDMTools) | |
# package:: fmsb | |
if("fmsb" %in% rownames(installed.packages()) == FALSE) | |
install.packages("fmsb") | |
library(fmsb) | |
# package:: graphics | |
if("graphics" %in% rownames(installed.packages()) == FALSE) | |
install.packages("graphics") | |
library(graphics) | |
# package:: corrplot | |
if("corrplot" %in% rownames(installed.packages()) == FALSE) | |
install.packages("corrplot") | |
library(corrplot) | |
# package:: forecast | |
if("forecast" %in% rownames(installed.packages()) == FALSE) | |
install.packages("forecast") | |
library(forecast) | |
# package:: vars | |
if("vars" %in% rownames(installed.packages()) == FALSE) | |
install.packages("vars") | |
library(vars) | |
# package:: tseries | |
if("tseries" %in% rownames(installed.packages()) == FALSE) | |
install.packages("tseries") | |
library(tseries) | |
# package:: TTR | |
if("TTR" %in% rownames(installed.packages()) == FALSE) | |
install.packages("TTR") | |
library("TTR") | |
# package:: ECP | |
if("ecp" %in% rownames(installed.packages()) == FALSE) | |
install.packages("ecp") | |
library("ecp") | |
# package:: BCP | |
if("bcp" %in% rownames(installed.packages()) == FALSE) | |
install.packages("bcp") | |
library("bcp") | |
# gdata | |
if("gdata" %in% rownames(installed.packages()) == FALSE) | |
install.packages("gdata") | |
library("gdata") | |
# stats | |
if("stats" %in% rownames(installed.packages()) == FALSE) | |
install.packages("stats") | |
library("stats") | |
# caret | |
if("caret" %in% rownames(installed.packages()) == FALSE) | |
install.packages("caret") | |
library("caret") | |
######################################################################################## | |
# Connect to PostgreSQL/Greenplum/HAWQ | |
drv <- dbDriver("PostgreSQL") | |
con <- dbConnect(drv, | |
host='#######', | |
port='5432', | |
dbname='#######', | |
user='#######', | |
password='#######') | |
# Example | |
# query <- paste("SELECT * FROM schema.table") | |
# d <- dbGetQuery(con, query) | |
######################################################################################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment