# Create a temporary folder for the output and set the working directory:
temp_path <- file.path(tempdir(), "ss3sim-tv-example")
dir.create(temp_path, showWarnings = FALSE)
wd <- getwd()
setwd(temp_path)
# Find the SS3 "Simple" model in the package data:
d <- system.file("extdata", package = "ss3sim")
simple <- paste0(d, "/Simple")
dir.create("Simple")
file.copy(simple, ".", recursive = TRUE)
setwd("Simple")
# Run SS3 to create control.ss_new and Report.sso:
system("ss3_24o_safe starter.ss -noest")
change_tv(change_tv_list = list("NatM_p_1_Fem_GP_1" = c(rep(0, 20),
rep(.1, 11)), "SR_BH_steep"=rnorm(31, 0, 0.05)), ctl_file_in =
"control.ss_new", ctl_file_out = "example.ctl", dat_file_in =
"simple.dat", dat_file_out = "example.dat")
# Clean up:
setwd("../")
unlink("Simple")
setwd(wd)
Run the code above in your browser using DataLab