Skip to content

Instantly share code, notes, and snippets.

@rmarrotte
Last active December 20, 2018 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmarrotte/25bcbdf18144dcda3410 to your computer and use it in GitHub Desktop.
Save rmarrotte/25bcbdf18144dcda3410 to your computer and use it in GitHub Desktop.
Simple script that shows how to run Circuitscape through R under Windows. It runs an examples found in the Circuitscape examples folder
########################################
#### Getting started ####
########################################
# Make a place holder for the cs_run.exe path
CS_exe <- 'C:/"Program Files"/Circuitscape/cs_run.exe' # Don't forget the "Program Files" problem
# We want to run one of the CS examples found in /examples/, first we need to fix the .ini file
# We first read in the .ini file and then we change the arguments
Example_lines <- readLines("C:/Program Files/Circuitscape/examples/eight_neighbor_example.ini")
Example_lines # The paths aren't correct, need to fix lines 5, 8, 11, 12, 13 and 14
# Basically we just need to append 'C:/Program Files/Circuitscape/' to all of them
Example_lines <- gsub(Example_lines,pattern = " ./",replacement = ' C:/Program Files/Circuitscape/')
writeLines(Example_lines, "myini.ini") # Write it to your directory
# Now we should be able to run the example
CS_run <- paste(CS_exe, paste(getwd(),"myini.ini",sep="/")) # Make the cmd
system(CS_run) # Run the command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment