Learn R Programming

ss3sim (version 1.0.3)

sample_lcomp: Sample length compositions from a Stock Synthesis data file

Description

Extract length-composition data from a .ss_new data file and sample the data. It is assumed that the composition data will be expected values as written by Stock Synthesis in the second section of the data file, but one can also sample input data. The resulting length-composition data are assumed to represent observed length composition and will overwrite the length data in dat_list, which is returned invisibly. The data file can also be written to the disk, if a file path is provided to outfile, and used as simulated data by an estimation model. If used with run_ss3sim, the case file should be named agecomp. A suggested (default) case letter is D for data.

Usage

sample_lcomp(dat_list, outfile, fleets, Nsamp, years, cpar = 1,
  ESS = NULL)

Value

A modified .dat file if !is.null(outfile). A list object containing the modified .dat file is returned invisibly.

Which arguments to specifiy in case files

All function argument descriptions that start with an asterisk (*) will be passed through the case files to run_ss3sim. If one of these arguments is not specified in a case file, then a value of NULL will be passed, which may or may not be an appropriate value. Other arguments will be ignored if specified.

See Also

sample_agecomp for more examples

Other sampling functions: clean_data, sample_agecomp, sample_calcomp, sample_index, sample_mlacomp, sample_wtatage

Examples

Run this code
# NOT RUN {
dat_list <- r4ss::SS_readdat(verbose = FALSE,
  file = system.file(file.path("extdata", "models", "cod-om", "codOM.dat"), 
  package="ss3sim"))
## Generate with constant sample size across years
ex1 <- sample_lcomp(dat_list=dat_list, outfile = NULL, 
  fleets = 1:2, Nsamp = list(100, 50), 
  years=list(seq(26, 100, by = 2), 80:100))

# }

Run the code above in your browser using DataLab