Pacific-Design.com

    
Home Index

1. R Langauge

+ 3D Plot

+ Database Interface

+ Installation

R Langauge /

Statistical Computing with R Language


#!/usr/bin/env Rscript
#---------------------------------------------------------------------------------------------#
library(RMySQL)
#---------------------------------------------------------------------------------------------#

dataAnalysis <- function() {

    mydb = dbConnect(MySQL(), user='root', password='password', dbname='engine3', host='localhost')

#-- Query Table
    	rs = dbSendQuery(mydb, "SELECT countryName FROM healthcare ORDER BY RAND() LIMIT 25;")
    	result1 = fetch(rs, n=-1)
    	print(result1)

#-- Create Table 
    	dbWriteTable(mydb, name='result1', value=as.data.frame.matrix(result1)
    	            , overwrite=TRUE, append=FALSE, row.names=0)

#-- Get List of Tables within database
    	list1 = dbListTables(mydb)
    	print(list1)

#-- Get result2 from result1
    	rs = dbSendQuery(mydb, "SELECT * FROM result1;")
    	result2 = fetch(rs, n=-1)
    	print(result2)
}

#---------------------------------------------------------------------------------------------#

dataAnalysis()

Links

Machine Learning


#-----------------------------------------------------------------------------------------#
# install.packages("getURL")
# install.packages(c("grid","plyr"))
#-----------------------------------------------------------------------------------------#

setwd('/Users/kduraj/Desktop/data')
data    <- read.table("mapdata_copyright_openstreetmap_contributors.txt",sep=",",header=T)
weather <- read.table("weather.csv",sep=",",header=T)
spray   <- read.table("spray.csv",sep=",",header=T)

#-----------------------------------------------------------------------------------------#
data(votes.repub)
agn1 <- agnes(votes.repub, metric = "manhattan", stand = TRUE)
agn1
plot(agn1)
library("cluster", lib.loc="~/Library/R/3.1/library")
#-----------------------------------------------------------------------------------------#