Hi, I'm writing a package called rNMR and I'd like to be able to save a workspace with rNMR loaded, exit R, and then load the workspace, loading rNMR at the same time. This is no problem on Windows but on Linux and Macs I can't get it to work. Here's the deal. rNMR has includes a .onLoad function:
.onLoad = function(lib,pkg){ print("rNMR version 1.0") } and also calls a different function which writes a .First to the global environment: .First <- function(){ require(rNMR) } Actually these have been simplified from there original versions in order to easier diagnose the problem. I've tested both versions and neither work. I open R and load rNMR. I know .onLoad runs because I see [1] "rNMR version 1.0" in R. Then I create the .First function as above (normally this is done internally by rNMR, but I'm doing this manually here to ensure it gets done correctly). Just to make sure I check that .First is in the right place: > getAnywhere(.First) 2 differing objects matching ‘.First’ were found in the following places .GlobalEnv namespace:rNMR Use [] to view one of them > .First function(){ require(rNMR) } Both versions of .First are identical. So, you'd expect that if I saved this workspace and exited, when I reopen R and load the workspace, .First should run, loading the rNMR package, and calling .onLoad. Here's what I get when I load the workspace: > load("/home/undergrad/Desktop/test.RData") [1] "rNMR version 1.0" but if I check for rNMR: > search() [1] ".GlobalEnv" "package:stats" "package:graphics" [4] "package:grDevices" "package:utils" "package:datasets" [7] "package:methods" "Autoloads" "package:base" it's clearly not attached. I can't access any rNMR functions without loading rNMR again. .First still exists in the workspace, but somehow rNMR hasn't loaded. If this is the case, why is .onLoad running (indicated by the printed rNMR version info)? Odder still, the original version of .First was designed to open a tk toplevel containing rNMR menus, which it does. Commands from these menus work but commands typed in the console don't and everything else seems to indicate that rNMR is not attached. Any thoughts? Thanks in advance, Seth -- View this message in context: http://www.nabble.com/.First-and-loading-a-package-in-a-workspace-tp23431418p23431418.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.