Skip to content

Commit 74ad983

Browse files
committed
add example_SimASAP.R and Rbuildignore examples
1 parent 0dc2b95 commit 74ad983

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

.Rbuildignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
^simASAP\.Rproj$
2+
^\.Rproj\.user$
3+
^LICENSE\.md$
4+
^\./examples$

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: simASAP
22
Title: Simulate ASAP Data Sets and Optionally Run Them
3-
Version: 0.0.0.9004
3+
Version: 0.0.0.9005
44
Authors@R:
55
person(given = "Chris",
66
family = "Legault",

examples/example_SimASAP.R

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# example_SimASAP.R
2+
# walks the user through a set of examples
3+
4+
library("simASAP")
5+
library("ggplot2") # shouldn't need to do this but doesn't seem to work otherwise
6+
7+
# first define where your original ASAP run is located
8+
base.dir <- "C:\\Users\\chris.legault\\Desktop\\testSimASAP"
9+
my.asap.name <- "simplelogistic"
10+
11+
# run simASAP with defaults to create 10 data sets
12+
SimASAP(wd=base.dir, asap.name=my.asap.name, nsim=10)
13+
# the C:\\Users\\chris.legault\\Desktop\\testSimASAP\\sim directory should have been created
14+
# in this new directory open up two or more of the simplelogistic_simX.dat files
15+
# and compare the Fleet-1 Catch Data (lines 164-184) and Index-1 and Index-2 Data (lines 281-322)
16+
# with each other and the original run to see that they have changed
17+
# can do this by hand or using the ReadASAP3DatFile function
18+
datorig <- ReadASAP3DatFile(file.path(base.dir, paste0(my.asap.name, ".dat")))
19+
od <- file.path(base.dir, "sim")
20+
datsim1 <- ReadASAP3DatFile(file.path(od, paste0(my.asap.name, "_sim1.dat")))
21+
datsim2 <- ReadASAP3DatFile(file.path(od, paste0(my.asap.name, "_sim2.dat")))
22+
rbind(datorig$dat$CAA_mats[[1]][1, ],
23+
datsim1$dat$CAA_mats[[1]][1, ],
24+
datsim2$dat$CAA_mats[[1]][1, ])
25+
# note the original file has the catch at age in proportions (the first 10 columns),
26+
# while the simulated files have the catch at age in numbers (which will be converted to proportions by ASAP automatically when the program is run)
27+
28+
# now actually run ASAP for a new set of random errors
29+
SimASAP(wd=base.dir, asap.name=my.asap.name, nsim=10, runflag=FALSE)

0 commit comments

Comments
 (0)