由于网上对于ROracle的安装不是最新的,所以贴出最新的额安装过程分享。
ROacle安装:
一、前期准备工作:
1、下载R语言:https://www.r-project.org/
2、下载Oracle instantclient下载:32bits、64bits
3、下载ROracle_1.2-1.zip:http://download.csdn.net/detail/chenchudongsg/9684825
二、安装过程(我的机子是64位的):
1、打开RGUI,
2、执行library(Rserve);Rserve(),查看R语言环境是否安装好
3、
说明:#转到ROracle_1.2-1.zip文件路径,下面是我存放的ROracle_1.2-1.zip文件的路径
setwd("C:/Program Files/R/R-3.3.2/bin/x64/")
说明:开始安装
install.packages("ROracle_1.2-1.zip",repos = NULL)
4、实现与oracle的连接
先配置环境变量,解压instantclient之后:
OCI_LIB64=D:\RScript\64\instantclient_11_2
PATH=C:\Program Files\R\R-3.3.2\bin\x64;D:\RScript\64\instantclient_11_2
若没有配置上述的环境变量,会出现如下错误:提示不是有效的wind32程序
library('ROracle') Error in inDL(x,as.logical(local),54)">now ...): unable to load shared object 'C:/Users/Daniel/R/winlibrary/3.2/ROracle/libs/x64/ROracle.dll'LoadLibrary failure%1isnot a valid Win32 application配置好环境变量之后,连接oracle:
> library("ROracle");
载入需要的程辑包:DBI
> drv <-dbDriver("Oracle")
> connect.string <-"(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT =1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))"
> con <- dbConnect(drv,username = "iind_1609",password = "iind_1609",dbname = connect.string)
> rs <- dbSendQuery(con,"select * from CFG_DB ")
> data<-fetch(rs);
> data截图如下出现结果:
安装中出现的问题,解决的来源:
1、http://stackoverflow.com/questions/36802847/roracle-installation-unable-to-load-shared-object-error
2、http://stackoverflow.com/questions/18046324/how-to-install-roracle-package-on-windows-7