Skip to content

Instantly share code, notes, and snippets.

@tbates
Last active August 29, 2015 14:00
Show Gist options
  • Save tbates/11298531 to your computer and use it in GitHub Desktop.
Save tbates/11298531 to your computer and use it in GitHub Desktop.
Beta download script
# http://openmx.psyc.virginia.edu/getOpenMxBeta.R
if(version$major < 3) {
stop("We don't have beta for R 2.15 or below. Consider upgrading to R 3.1?\n
You can get this from http://cran.r-project.org/")
}
if (.Platform$OS.type == "windows") {
if (!is.null(.Platform$r_arch) && .Platform$r_arch == "x64") {
repos <- c('http://openmx.psyc.virginia.edu/testing/')
} else {
repos <- c('http://openmx.psyc.virginia.edu/testing-32bit/')
}
install.packages(pkgs = c('OpenMx'), repos = repos)
} else {
darwinVers <- as.numeric(substr(Sys.info()['release'], 1, 2))
if (Sys.info()["sysname"] == "Darwin" && darwinVers > 10) {
# = User is on OS X without default OpenMP support =
msg <- paste("We have detected that you are running on OS X 10.7 or greater.\n",
"The default gcc compiler does not support parallel execution.\n",
"If you have installed a gcc that supports OpenMP (say mac ports gcc)\n",
" choose the multi-threaded installation option.\n",
"Otherwise stay with default installation (single-threaded), i.e., '1'.\n\n"
)
cat(msg)
msg1 = "1. single-threaded [default]\n"
msg2 = "2. multi-threaded \n"
default = 1
} else {
# = unix with OpenMP =
msg1 = "1. single-threaded\n"
msg2 = "2. multi-threaded [default]\n"
default = 2
}
# ===================
# = get user choice =
# ===================
cat(msg1)
cat(msg2)
select <- readline("Which version of OpenMx should I install? ")
if (select == "") { select <- default }
while (!(select %in% c(1, 2))) {
message("Please enter '1' or '2'. You entered '", select, "'")
select <- readline("Which version of OpenMx should I install? ")
}
# ==================
# = Do the install =
# ==================
if (select == 1) {
repos <- c('http://openmx.psyc.virginia.edu/testing-sequential/')
install.packages(pkgs = c('OpenMx'), repos = repos, configure.args = c('--disable-openmp'))
} else if (select == 2) {
repos <- c('http://openmx.psyc.virginia.edu/testing/')
install.packages(pkgs = c('OpenMx'), repos = repos)
}
}
@tbates
Copy link
Author

tbates commented Apr 25, 2014

  1. Stop if R < 3
  2. Simplify logic
  3. While loop to get choice with feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment