R

Environment


setenv R_LIBS /path/to/user/R-libraries

# setting R_LIBS will change both where R looks for lib to load and when installing libs 



library( rJava );	# see if it can load the R library named rJava (case sensitive)


Oracle connection

Sys.setenv(TNS_ADMIN="/site/conf/TNS_ADMIN",ORACLE_HOME="/usr/prog/oracle-client/11.1.0.6",ORACLE_SID='')
# The TNS_ADMIN may not matter if ORACLE_HOME has a network/admin with working conf for tns name resolution.
# ORACLE_SID is very important!  if set, the instance specifier in the dbConnect will be ignored, and db always connect to instance specified by ORACLE_SID !!

library( 'ROracle' )

ora=Oracle()
con=dbConnect(ora,user='user/pass@instance')
summary(con)
# verify connected to desired db)

result=dbGetQuery(con, "select * from tab")
# perform SQL query

result
# see result of query (display content of variable)


result2=dbListTables( con )
# see list of tables for the connected schema

# = is likely std var assign
# <- is probably some sort of pointer assignment, pass by object reference kind of stuff ??









[Doc URL: http://tin6150.github.io/psg/ ]
Last Updated: 2008-03-22
(cc) Tin Ho. See main page for copyright info.


"ting"
"ting"
psg101 sn50 tin6150