Closed slucey closed 4 years ago
it all looks good. let me run a couple of tests before i merge
@slucey There is an issue with strat_prep.r. It references on line 62 :areaDescription but this is not passed as an argument to the function. This value used to be stored in the strat.col argument. I think just change areaDescription to strat.col should work
survdat::swept_area_biomass(data=data, areaDescription = "STRATA" ,filterByArea = "all", filterBySeason="FALL")
results in
Error in data.table::setnames(strat.survdat, c("STRAT", "S.AREA"), c(areaDescription, :
object 'areaDescription' not found
3.
data.table::setnames(strat.survdat, c("STRAT", "S.AREA"), c(areaDescription,
"Area")) at strat_prep.R#61
2.
survdat::strat_prep(filteredData, strat.area, strat.col = areaDescription) at swept_area_biomass.r#86
1.
survdat::swept_area_biomass(data$survdat, areaDescription = "STRATA",
filterByArea = "all", filterBySeason = "FALL")
Another issue in strat_mean (related to commit):
some columns are not in the data.table: STRATUM
In addition: Warning message:
Error in setkeyv(x, cols, verbose = verbose, physical = physical) :
some columns are not in the data.table: STRATUM
5.
stop("some columns are not in the data.table: ", paste(cols[miss],
collapse = ","))
4.
setkeyv(x, cols, verbose = verbose, physical = physical)
3.
data.table::setkey(x, CRUISE6, STRATUM, STATION, SVSPP, CATCHSEX) at strat_mean.R#40
2.
survdat::strat_mean(survdatPrep, groups = species, group.col = "SVSPP",
strat.col = areaDescription, poststrat = poststrat, merge.sex = merge.sex) at swept_area_biomass.r#89
1.
survdat::swept_area_biomass(data$survdat, areaDescription = "STRATA",
filterByArea = "all", filterBySeason = "FALL") ```
I replaced the areaDescription with strat.col in strat_prep.r and have fixed the issue with strat_mean.r by appending an extra column to a survey data set that is using the original stratified design and not being restratified. What was happening there was the original STRATUM column was being renamed to whatever the strat.col variable was but strat_mean had the STRATUM column hard coded to remove the length data from the data set. I'm going to play around a bit more and see if there is a more elegant solution.
I have switched up the code to use the pre-labeled strata numbers rather than using poststrat to identify strata when using the random stratified survey design of the survey.