1

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)
}
1
  • @ZheyuanLi -- It is blank now, but I can put the old version in the question. Jul 22, 2016 at 22:02

2 Answers 2

1

All the info your need is contained in ?Startup.

You likely just deleted the home folder .Rprofile for the current user. Perhaps you want to search for a Rprofile.site file within the /etc directory of your program files.

file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site") 
0

.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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.