Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[85da41]: R / windows / zzz.R Maximize Restore History

Download this file

zzz.R    71 lines (60 with data), 2.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
.findKey <- function(keyname)
{
if (identical(.Platform$r_arch, "x64")) {
keyname <- paste(keyname,"-x64", sep="")
}
## Look for multi-user installation in registry
regkey <- try(readRegistry(keyname, hive = "HLM", maxdepth = 1),
silent = TRUE)
if (inherits(regkey, "try-error")) {
## Look for single-user installation in registry
regkey <- try(readRegistry(keyname, hive = "HCU", maxdepth = 1),
silent = TRUE)
}
if (inherits(regkey, "try-error") || is.null(regkey[["InstallDir"]])) {
##Give up
return(NULL)
}
return (regkey[["InstallDir"]])
}
.onLoad <- function(lib, pkg)
{
### First task is to get installation directory of JAGS
## Try environment variable first
jags.home <- Sys.getenv("JAGS_HOME")
if (nchar(jags.home)==0) {
jags.home <- .findKey("SOFTWARE\\JAGS\\JAGS-2.2.0")
if (is.null(jags.home)) {
jags.home <- .findKey("SOFTWARE\\JAGS\\JAGS-2.2.0")
}
if (is.null(jags.home)) {
stop("Failed to locate JAGS 2.2.0 installation.\n",
"The rjags package is just an interface to the JAGS library\n",
"which must be separately installed\n",
"See http://www.sourceforge.net/projects/mcmc-jags/files\n")
}
}
### Add jags.home to the windows PATH, if not already present
bindir <- file.path(jags.home, "bin")
path <- Sys.getenv("PATH")
split.path <- strsplit(path, .Platform$path.sep)$PATH
if (!any(split.path == bindir)) {
path <- paste(bindir, path, sep=.Platform$path.sep)
Sys.setenv("PATH"=path)
}
### Set the module directory, if the option jags.moddir is not already set
if (is.null(getOption("jags.moddir"))) {
options("jags.moddir" = file.path(jags.home, "modules"))
}
library.dynam("rjags", pkg, lib)
load.module("basemod")
load.module("bugs")
### Set progress bar type
if (is.null(getOption("jags.pb"))) {
options("jags.pb"="text")
}
}
.onUnload <- function(libpath)
{
library.dynam.unload("rjags", libpath)
}