I used to have a dbConnect
statement as .First
in my .Rprofile
and a dbDisconnect
statement as .Last
. I no longer need these, so I removed them from .Rprofile
, but R hangs when I exit because of the dbDisconnect
statement. I can quit with q(runLast=F)
.
> q()
Error in .Last() : could not find function "dbDisconnect"
I put an empty .Rprofile
in my root, but I still get this error. I have the default Rprofile.site
.
What causes this? Is there a fix? FWIW, I am on Windows 8.1 with R 3.3.1.
My .Rprofile
is blank now. But it used to contain the following.
library(rJava)
.jinit(parameters="-Xmx8g")
library(RJDBC)
user <- "my_username"
pass <- '{SAS002}DBCC5712369DE1C65B19864C1564FB850F398DCF'
wrdsconnect <- function(user=user, pass=pass){
drv <- JDBC("com.sas.net.sharenet.ShareNetDriver", "/usr/local/sas/jdbc_driver/sas.intrnet.javatools.jar", identifier.quote="`")
wrds <- dbConnect(drv, "jdbc:sharenet://wrds-cloud-h.wharton.private:8551/", user, pass)
return(wrds)
}
.First <- function(){
wrds <<- wrdsconnect(user=user, pass=pass)
}
.Last <- function(){
dbDisconnect(wrds)
}
.Last
can also hide in .Rdata
. My text editor opens R scripts in its program folder, where I had saved a work space with this .Last
. Every time I opened R from a script in my text editor (my usual) it loaded this .Last
.
No matter what you do to your .Rprofile
and Rprofile.site
, this will continue until you either delete this .Rdata
or start in another directory.