Generate a selectivity sheet describing data and gathering a set of selectivity indicators.
create_selectivity_sheet(
data,
protocol,
output_dir = NULL,
output_file = NULL,
min_length = NULL,
language = "EN",
zones
)data.frame A data.frame as generated by prep_sel_data()
character Type of protocol. "twin" for experiment where both fishing gear are deployed in the same fishing operation (e.g. using twin trawls) ; "paired" for experiment where the two fishing gear are deployed in a set of 'pairs' : two different fishing operations, but in very similar conditions; "unpaired" for experiment where the gear are tested independently in two different samples of fishing operations.
character Directory name where the sheet should be written
character Name of the file for the sheet
numeric Optional. For species analyzed in length, the minimum targeted length for selectivity (e.g., MCRS) for graphics and statistics. A data.frame with a column 'species' and a column 'min_length' for the corresponding minimum length.
character English by default ("EN"). Can be passed in French ("FR").
character The vector of zones used in the report.
None A HTML file is generated in the output_dir as well as all the figures in png.
For more details on the selectivity sheet format, see the related vignette :
vignette("create-selectivity-sheet", package = "inser")
# Create tmp folder
output_dir <- tempfile(pattern = "inser")
dir.create(output_dir)
# Setup input OTT data
OTT_data_folder <- system.file("script_origin","Data","Example_OTT", package = "inser")
TR <- readr::read_delim(
file = file.path(OTT_data_folder, "TR.csv"),
delim = ";",
escape_double = FALSE,
locale = readr::locale(encoding = "WINDOWS-1252"),
trim_ws = TRUE
)
#> Rows: 2 Columns: 31
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (12): sampling_type, landing_country, vessel_flag_country, project, harb...
#> dbl (11): trip_code, year, vessel_length, vessel_power, vessel_size, vessel_...
#> lgl (8): number_of_sets, days_at_sea, departure_date_time, return_date_time...
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
HH<-read.table(
file.path(OTT_data_folder, "HH.csv"),
sep=";",
header=TRUE,
encoding = "WINDOWS-1252")#,colClasses = colClasses)
SL<-read.table(
file.path(OTT_data_folder, "SL.csv"),
sep=";",
header=TRUE,
encoding = "WINDOWS-1252")
HL<-read.table(
file.path(OTT_data_folder, "HL.csv"),
sep=";",
header=TRUE,
encoding = "WINDOWS-1252")
colClasses<-rep(NA,ncol(HH))
colClasses[which(names(HH)=="statistical_rectangle")]<-"character"
HH<-read.table(
file.path(OTT_data_folder, "HH.csv"),
sep=";",
header=TRUE,
colClasses = colClasses,
encoding = "WINDOWS-1252")
# create TAB output
TAB <- prep_sel_data(data=list(TR,HH,SL,HL))
# Setup zone and min_length params
min_length <- data.frame(species=unique(TAB$species),min_length=c(27,24,20,NA,27,NA))
zones <- c("8.a","8.b","7.d","7.e","7.h")
# run function
create_selectivity_sheet(data = TAB,
output_dir = output_dir,
output_file = "fiche_InseR_twin",
protocol = "twin",
language = "FR",
zones=zones,
min_length=min_length)
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
#> Using the FR version of the selectivity template
#>
#>
#> processing file: selectivity_sheet_twin.Rmd
#> 1/61
#> 2/61 [unnamed-chunk-1]
#> 3/61
#> 4/61 [unnamed-chunk-2]
#> 5/61
#> 6/61 [maps]
#> 7/61
#> 8/61 [fishing_duration]
#> 9/61
#> 10/61 [fishing_depth]
#> 11/61
#> 12/61 [vessel_speed]
#> 13/61
#> 14/61 [sea_state]
#> 15/61
#> 16/61 [wind_force]
#> 17/61
#> 18/61 [seabed]
#> 19/61
#> 20/61 [wind_direction]
#> 21/61
#> 22/61 [day_night]
#> 23/61
#> 24/61 [unnamed-chunk-3]
#> 25/61
#> 26/61 [total_catch_weight]
#> 27/61
#> 28/61 [sorting_time]
#> 29/61
#> 30/61 [unnamed-chunk-4]
#> 31/61
#> 32/61 [unnamed-chunk-5]
#> 33/61
#> 34/61 [fraction_weights]
#> 35/61
#> 36/61 [unnamed-chunk-6]
#> 37/61
#> 38/61 [unnamed-chunk-7]
#> 39/61
#> 40/61 [unnamed-chunk-8]
#> 41/61
#> 42/61 [unnamed-chunk-9]
#> 43/61
#> 44/61 [unnamed-chunk-10]
#> 45/61
#> 46/61 [unnamed-chunk-11]
#> 47/61
#> 48/61 [fraction_species_weights]
#> 49/61
#> 50/61 [unnamed-chunk-12]
#> 51/61
#> 52/61 [unnamed-chunk-13]
#> 53/61
#> 54/61 [unnamed-chunk-14]
#> 55/61
#> 56/61 [size_distribution_species]
#> 57/61
#> 58/61 [unnamed-chunk-15]
#> 59/61
#> 60/61 [relative_size_selectivity_species]
#> 61/61
#> output file: selectivity_sheet_twin.knit.md
#> /opt/hostedtoolcache/pandoc/3.1.11/x64/pandoc +RTS -K512m -RTS selectivity_sheet_twin.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/RtmpN5ho0X/inser224e3bb86dc5/fiche_InseR_twin.html --lua-filter /home/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --variable toc_print=1 --template /home/runner/work/_temp/Library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --number-sections --variable theme=lumen --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/RtmpN5ho0X/rmarkdown-str224e6b60af1e.html
#>
#> Output created: /tmp/RtmpN5ho0X/inser224e3bb86dc5/fiche_InseR_twin.html
# rstudioapi::filesPaneNavigate(output_dir)
# Clear tmp folder
unlink(output_dir, recursive = TRUE)