runMarxan
runMarxan.Rd
runMarxan
Arguments
- os
character for the operating system. Either "win" (default), "linux", "macos", or "macosM1"
- marxanpath
character string for the directory of the Marxan executable. Default is the current working directory.
- inputdatfile
character string for the file path for the Marxan input parameter file. Default is "input.dat" in the "marxanpath" directory. If there is a file that matches a relative path "inputdatfile" relative to both the user's current working directory AND the "marxanpath" directory, this function will use the file in the "marxanpath" directory.
Examples
runMarxan
#> function (os = "win", marxanpath = getwd(), inputdatfile = file.path(marxanpath,
#> "input.dat"))
#> {
#> old <- getwd()
#> on.exit(setwd(old))
#> setwd(marxanpath)
#> if (os == "win") {
#> exec <- "Marxan_x64.exe"
#> }
#> else if (os == "linux") {
#> exec <- "marxan"
#> stop("This only works on Windows for now!")
#> }
#> else if (os == "macos" | os == "macosM1") {
#> exec <- "marxan"
#> stop("This only works on Windows for now!")
#> }
#> else {
#> stop("This only works on Windows for now!")
#> }
#> if (!file.exists(exec)) {
#> stop(paste("The Marxan executable (", file.path(getwd(),
#> exec), ") does not exist. Verify 'os' and 'marxanpath' arguments"))
#> }
#> if (file.exists(inputdatfile)) {
#> input <- inputdatfile
#> }
#> else if (file.exists(file.path(old, inputdatfile))) {
#> message(paste("Interpreting 'inputdatfile' as a relative path to your current working directory:",
#> file.path(old, inputdatfile)))
#> input <- file.path(old, inputdatfile)
#> }
#> else {
#> stop(paste("The Marxan input parameters file (i.e. input.dat) does not exist (",
#> inputdatfile, "). Verify the 'inputdatfile' argument"))
#> }
#> system2(exec, args = input)
#> }
#> <bytecode: 0x563397c79758>
#> <environment: namespace:marxanr>