Giter Club home page Giter Club logo

tropfishr's Introduction

TropFishR 🎣

License: GPL v3 Build Status CRAN version CRAN Downloads GitHub release DOI

Package description

TropFishR is a collection of fisheries models based on the FAO Manual "Introduction to tropical fish stock assessment" by Sparre and Venema (1998, 1999). Not only scientists working in the tropics will benefit from this new toolbox. The methods work with age-based or length-frequency data and assist in the assessment of data poor fish stocks. Overall, the package comes with 30 functions, 19 data sets and 10 s3 methods. All objects are documented and provide examples that allow reproducing the examples from the FAO manual.

News

You can find detailed descriptions of new features, bug fixes, other changes of specific package versions here.

Installation

Download the released version of TropFishR from CRAN:

install.packages("TropFishR")

Or the development version from GitHub:

# install.packages("remotes")
remotes::install_github("tokami/TropFishR")

Citation

Please use the R command citation("TropFishR") to receive information on how to cite this package.

Documentation

The tutorial demonstrates the use of the main functions of TropFishR for a single-species stock assessment with length-frequency data. The lfqDataTutorial gives a brief description of LFQ data and illustrates how files with raw length measurements (e.g. excel files) can be imported into R and trimmed for the use with TropFishR. The ELEFANTutorial demonstrates the ELEFAN functions available in TropFishR in detail and discusses best practices.

Questions / Issues

In case you have questions or find bugs, please write an email to Tobias Mildenberger or post on TropFishR/issues. If you want to be updated with the development of the package or want to discuss with TropFishR users and developers, follow the project on ResearchGate.

References

  1. Sparre, P., Venema, S.C., 1998. Introduction to tropical fish stock assessment. Part 1. Manual. FAO Fisheries Technical Paper, (306.1, Rev. 2). 407p. link
  2. Sparre, P., Venema, S.C., 1999. Introduction to tropical fish stock assessment. Part 2. Excercises. FAO Fisheries Technical Paper, (306.2, Rev. 2). 94p. link
  3. Mildenberger, T. K., Taylor, M. H. and Wolff, M., 2017. TropFishR: an R package for fisheries analysis with length-frequency data. Methods in Ecology and Evolution, 8: 1520-1527. doi:10.1111/2041-210X.12791 link
  4. Taylor, M. H., and Mildenberger, T. K., 2017. Extending electronic length frequency analysis in R. Fisheries Management and Ecology, 24:330-338. doi:10.1111/fme.12232 link

tropfishr's People

Contributors

alko989 avatar marchtaylor avatar tokami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tropfishr's Issues

ideas for improvement

  • option for variable size class intervals within functions or separate function which rearranges datasets
  • separate functions which create classes as input for functions? e.g. lfq in fisat...
  • output of functions should be class which can be used for plot function, create by class(argument) = "name of class"
  • separate plot functions, automatically using output classes of functions: output = class("VPA") plot(output) -> desired graph depending on class
  • plot option within function: plot = T or F

Error: Failed to install 'TropFishR' from GitHub:

Hi all,
I have been trying to use TropfishR package In fact, I got the same message below.
Screen Shot 2020-07-03 at 15 32 32

Error: package or namespace load failed for ‘TropFishR’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so, 6): Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so
Reason: image not found

If you have an idea to fix it and use package, I would be great
Best regards,
Tevfik

edit: Ps : R version 4.0.0 Patched (2020-05-03 r78349) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

ESP scoring

this should be done in a separate function to allow for use in other functions and interchangeability with new approaches

Linking means after Bhattacharya´s method

Dear Tobias Mildenberger,
Thanks a lot for the TropFishR package!!!
I am new with TropFishR.
I appreciate if you could indicate which function I should use to run the "linking of means (to represent the same cohort ) after Bhattacharya's method using lenght frequency data".

Error in ELEFAN_SA

I am running the ELEFAN_SA() function. Here's the code:

sp_SA <- ELEFAN_SA(
  lfq = sp_rlfd,
  seasonalised = TRUE,
  init_par = list(
    Linf = Linf03,
    K = 1,
    t_anchor = 0.5,
    ts = 0.5,
    C = 0.5
  ),
  low_par = list(
    Linf = Linf03 - 2,
    K = 0.5,
    t_anchor = 0, ts = 0, C = 0
  ),
  up_par = list(
    Linf = Linf03 + 2,
    K = 1.5,
    t_anchor = 1, ts = 1, C = 1
  ),
  SA_temp = 2e5,
  SA_time = 60 * 5,
  maxit = 500,
  MA = 5,
  plot.score = TRUE,
  verbose = FALSE
)

However, I got this error:

Simulated annealing is running. 
This will take approximately 1 minutes.
value: 39
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  no rows to aggregate

P.S. The code above works fine while I am on Arch Linux. Currently, I migrated to Debian 12.

Currently using TropFishR version 1.6.2 (I tried using 1.6.3 but I encountered similar error).

Edit 1: I also tried the 1.6.0 version ("nojags"), but same error.
Edit 2: Same issue when I tried to run it in a virtual machine running Linux Mint and Manjaro.
Edit 3: By the way, here's the data I used: data

Here's the sessionInfo()

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 12 (bookworm)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so;  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_PH.UTF-8       LC_NUMERIC=C               LC_TIME=en_PH.UTF-8        LC_COLLATE=en_PH.UTF-8    
 [5] LC_MONETARY=en_PH.UTF-8    LC_MESSAGES=en_PH.UTF-8    LC_PAPER=en_PH.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_PH.UTF-8 LC_IDENTIFICATION=C       

time zone: Asia/Manila
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] TropFishR_1.6.2    RColorBrewer_1.1-3 data.table_1.14.10 here_1.0.1        

loaded via a namespace (and not attached):
 [1] crayon_1.5.2      doParallel_1.0.17 cli_3.6.2         zoo_1.8-12        bit_4.0.5         msm_1.7.1         tmvtnorm_1.6     
 [8] gmm_1.8           rprojroot_2.0.4   ff_4.0.9          stats4_4.3.2      grid_4.3.2        expm_0.999-8      MASS_7.3-60      
[15] foreach_1.5.2     mvtnorm_1.2-4     propagate_1.0-6   compiler_4.3.2    codetools_0.2-19  sandwich_3.1-0    Rcpp_1.0.11      
[22] GenSA_1.1.12      lattice_0.22-5    parallel_4.3.2    splines_4.3.2     minpack.lm_1.2-4  Matrix_1.6-1.1    tools_4.3.2      
[29] iterators_1.0.14  GA_3.2.3          survival_3.5-7   

demo file excel

Please share the demo file in excel for each in data
Quang

improve Bhattacharya

  • by choosing 2 to 10 and 12 to 20 an extremely high value is produced for the third run....
  • no return argument
  • what happens if one point is chosen and then one presses "finished" ?
  • add clear documentation

Bug in Z_CPUE

noted by Hadi:

  • remove CPUE[4] <- sum(CPUE[4:length(CPUE)]) in Heincke and Chapman method
  • replace sum_CPUE.H.n <- sum(CPUE[2:length(CPUE)]) with sum_CPUE.H.n <- sum(CPUE[2:length(CPUE)] * 1:(length(CPUE)-1))

Error: Failed to install 'TropFishR' from GitHub

Hi, I'm using Mac device and I was unable to install 'TropFishR' from GitHub and some errors appeared as below:

Installing 23 packages: rlang, digest, backports, diffobj, waldo, ps, callr, brio, cli, R6, labeling, testthat, tibble, xfun, htmlwidgets, sandwich, iterators, data.table, Formula, foreach, ff, RcppArmadillo, doParallel
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/rlang_0.4.8.tgz'
Error in download.file(url, destfile, method, mode = "wb", ...) :
(converted from warning) URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/rlang_0.4.8.tgz': status was 'SSL connect error'
Error: Failed to install 'TropFishR' from GitHub:
(converted from warning) download of package ‘rlang’ failed

library(TropFishR)
Error: package or namespace load failed for ‘TropFishR’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so, 6): Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so
Reason: image not found
In addition: Warning message:
package ‘TropFishR’ was built under R version 4.0.2

Note that I'm using ''R'' version 4.0.1 (2020-06-06) --
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit).

would you please help to solve the issues with Mac device.

Thank you.

ypr function

Dear developer,
I have problem in run the command ypr. I am using the following code:

devtools::install_github("tokami/TropFishR")
require(TropFishR)
Winf=(0.000006*30)^3.085
m=mean(as.vector(c(0.755, 0.567, 0.483)))
param=list(Linf=30,Winf=Winf,K=0.24,t0=-0.61,M=m,tr=0.25,tc=0.5)

#param a list consisting of following parameters (not all are required):
#• Linf: infinite length in cm,
#• Winf: infinite weight,
#• K: growth coefficent for investigated species per year [1/year],
#• t0: theoretical time zero, at which individuals of this species hatch,
#• M: natural mortality,
#• tr: age of recruitment,
#• tc: age of first capture;
#FM_change vector with ascending fishing mortalities,
#t default NA

ypr(param, FM_change=seq(0,2,0.1))

Thank you in advance for your help,
Isabella

One cohort analysis

I am trying to apply the ELEFAN routine to jellyfish, their lifespan oscilates typically from 1 to 4 months making it hard to differenciate between cohorts as some of them might be spaced just for 15 days instead of a whole year. However, for one of the species I am completely sure that for the whole lifespan I only have 1 cohort but when I throw the analysis I receive a ncohort of 4, being it extremely high given the loleny recruitment peak registered for the data. Is it possible to fix the ncohort before running ELEFAN so I can get a K value more consistent with the input data?

select_ogive()

revise the lognormal option. Which parameters are required? mu and sigma correspond to mode length and standard deviation? run examples with same dataset "tilapia" using parameters resulting from select() or select_Millar().

Powell Weatherall with LFQ object

An example of powell_wetherall() should be included to show how lfq data like synLFQ5 can be translated into the function (i.e. convert to catches for the year)

Error in lfqModify command, with the argument 'vectorise_catch'

Hi
Thanks for TropFishR package
I have problem with lfqModify
each time running the code lfq_sum <- lfqModify(synLFQ4, vectorise_catch = TRUE) this errors will display:

Error in lfqModify(synLFQ4, vectorise_catch = TRUE) : 
  unused argument (vectorise_catch = TRUE)

How I can fix this issue?
Thanks in advance
Mohammad

`

Error in catchCurve

Hi, @tokami. I am recently having an error in completing the catchCurve and I am confused. I tried the code
selar_res_cc <- catchCurve(selar_lfq_catch_vec,
catch_columns = c(1, 2),
reg_int = c(10.5, 14.5),
calc_ogive = TRUE)

Here is the error message:
Error in catchCurve(selar_lfq_catch_vec, catch_columns = c(1, 2), reg_int = c(10.5, :
You need to assign values to Linf and K for the catch curve based on length-frequency data!

What should I do?

Development version not installing

install.packages(devtools)
Error in install.packages : object 'devtools' not found
devtools::install_github(“tokami/TropFishR”)
Error: unexpected input in "devtools::install_github(“"

make rtypes_Millar() an exported object

If you make rtypes_Millar an exported object, then it is useful for others to make a predictive selectivity function for published gillnet selectivity parameters. Alternatively you could make a predict function that works for all models included in select_Millar()

help(Bhattacharya)

Dear Tobias Mildenberger,

Thank you for creating TropFishR! I am new to the package and am having a few issues figuring it out.
I am trying to run the example set out in help(Bhattcharya) with the synLFQ1 data, but every time I select points 19 - 23 I am faced with the error code below:

Error in plot.window(xlim, ylim, "", ...) : need finite 'ylim' values
In addition: Warning messages:
1: In sqrt(-interval/b.co1) : NaNs produced
2: In rnorm(n = n_rnorm, mean = l.mean.co1, sd = s.co1) : NAs produced

Could you explain what I am doing wrong?

predict_mod() error: Error in if (!is.na(curr.E)) { : argument is of length zero

Hi @tokami ,

I have been playing around with TropFishR using some dummy data. Thank you for this package. At this point, I'm getting an error with the following.

> TB1 <- predict_mod(lfq_catch_vec, type = "ThompBell",
+                    FM_change = seq(0,1.5,0.05),
+                    stock_size_1 = 1,
+                    curr.E = lfq_catch_vec$par$E,
+                    s_list = selectivity_list,
+                    plot = FALSE, hide.progressbar = TRUE)

Error is:

Error in if (!is.na(curr.E)) { : argument is of length zero
In addition: Warning message:
In max(FM, na.rm = TRUE) : no non-missing arguments to max; returning -Inf

My lfq_catch_vec is below.

> lfq_catch_vec
$dates
[1] "2005-01-01" "2006-01-01" "2007-01-01"

$midLengths
[1] 11 13 15 17 19 21 23 25 27

$catch
   X2005 X2006 X2007
V1     5    11     2
V2    22    49    15
V3    66   139    22
V4   106   337    69
V5   166   477   133
V6   243   421   115
V7   209   308    68
V8   112   168    49
V9   105   145    19

$par
$par$Linf
[1] 27.18388

$par$K
[1] 0.7627744

$par$t_anchor
[1] 0.6635739

$par$C
[1] 0.5911645

$par$ts
[1] 0.6136335

$par$phiL
[1] 2.751019

$par$M
[1] 1.136

$par$FM
numeric(0)

$par$E
numeric(0)

$par$a
[1] 0.015

$par$b
[1] 3

$par$Lmat
[1] 35

$par$wmat
[1] 5


attr(,"class")
[1] "lfq"

My data has three years. So this now has three columns. Definitely above I can see that lfq_catch_vec$par$E is 0. But why is that? Have I done something suboptimal while generating this object? This is how I generated the lfq_catch_vec.

## define plus group as largest length class smaller than Linf
plus_group <- lfq_bin2$midLengths[max(which(lfq_bin2$midLengths < lfq_bin2$par$Linf))]

## summarise catch matrix into vector and add plus group
lfq_catch_vec <- lfqModify(lfq_bin2, vectorise_catch = TRUE, plus_group = plus_group)

And this is my lfq_bin2 object.

> lfq_bin2
$dates
 [1] "2005-04-15" "2005-05-15" "2005-07-15" "2005-08-15" "2005-09-15"
 [6] "2005-10-15" "2005-11-15" "2005-12-15" "2006-01-15" "2006-02-15"
[11] "2006-03-15" "2006-04-15" "2006-05-15" "2006-06-15" "2006-07-15"
[16] "2006-09-15" "2006-10-15" "2006-11-15" "2006-12-15" "2007-01-15"
[21] "2007-02-15" "2007-03-15"

$midLengths
 [1] 11 13 15 17 19 21 23 25 27 29 31

$catch
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
 [1,]    3    0    1    0    0    0    0    1    0     3     2     4     0
 [2,]    8    1    3    0    3    1    3    3    1     3     7    17     3
 [3,]   17    6    6    3    4    4   17    9    7     6    11    31     7
 [4,]   16   20   11    6   12   11   16   14   38    15    15    32    20
 [5,]   31   27   11   11   20   21   22   23   48    34    35    55    25
 [6,]   22   60   45   42   22   21   11   20   41    35    45    49    58
 [7,]   22   38   29   30   28   27   21   14   24    28    38    48    38
 [8,]   17   18   13    6   23   23    5    7   13    14    20    35    14
 [9,]    9   15   11    5   11   11    4    4    2    10    14    19    12
[10,]    6    7    4    2    3    3    1    1    0     5    11    10    12
[11,]    1    2    2    0    1    0    2    0    0     2     4     6     3
      [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
 [1,]     0     0     2     0     0     0     1     1     0
 [2,]     1     4     5     6     1     1     2     9     4
 [3,]     4    15    32    12    11     3     4     5    13
 [4,]     7    47    50    30    64    19    31    33     5
 [5,]     8    78    44    50    71    29    52    57    24
 [6,]    16    67    26    25    41    18    46    41    28
 [7,]    10    41    17    26    24    14    28    31     9
 [8,]     4    16     6    15    17    14    19    25     5
 [9,]     5     7     3     1     6     2     5     5     4
[10,]     3     2     1     0     2     0     2     1     1
[11,]     1     2     0     0     0     0     1     0     0

$par
$par$Linf
[1] 27.18388

$par$K
[1] 0.7627744

$par$t_anchor
[1] 0.6635739

$par$C
[1] 0.5911645

$par$ts
[1] 0.6136335

$par$phiL
[1] 2.751019

$par$M
[1] 1.136


attr(,"class")
[1] "lfq"

You feedback is very much appreciated.

Thanks,
Shani.

How to input multi-year length frequency data in TropFishR Package for the stock assessment?

I am currently conducting research on shrimp stock assessment using the ‘TropFishR’ package to analyze a monthly carapace length frequency dataset. The package allows for the analysis of one year of data, specifically data collected from January to December of a particular year. Sample code for opening the library, working with an Excel file, and opening the dataset from the working directory is provided below:

Open the TropFishR library

library(TropFishR)

Open the Excel data file

library(openxlsx)

Set the working directory where the data is located

setwd

Open the dataset in the working directory

data <- read.xlsx("frequency.xlsx")

To reproduce the result

set.seed(1)

Define the date, assuming 15 as the midpoint of sampling days

1:12 indicates data collected from January to December

-2022 indicates the year, with the remaining codes remaining the same

dates <- as.Date(paste0("15-",01:12,"-2022"),format="%d-%m-%Y")
However, if we have more than one year of data, how can we feed it into the ‘TropFishR’ package?

catcurve calc_ogive

Hello! I can't run the example because after clicking in the 2 points of the curve I have an error message.
output <-catchCurve(synLFQ3, calc_ogive = TRUE)
Please choose the minimum and maximum point in the graph
to include for the regression line!
Error in xy.coords(x, y) : 'x' and 'y' lengths differ
In addition: Warning messages:
1: In if (I == which(ind)) { :
the condition has length > 1 and only the first element will be used
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
Thank you in advance for your response!

catchCurve

Dear Tobias Mildenberger,
I am having some trobles running "catchCurve" function. I modified my length-frequency data with the "lfqModify" function and, after run catchCurve the programm returns the following message:"Error: "x" must be numeric.". In fact the same message return when I run the examples contained in the help of the catchCurve function. It is maybe possible that the function is not working properly? I thank you in advance.

demanding more cleaning

  • find better ways to display non-ASCII character ± than +/- ,e.g. plotmath: %+-% in all CatchCurve functions
  • CatchCurve.R provokes a Warning message about /usage in Rd

general issue with dev.new() or quartz() and windows() respectively

get rid of quartz() and windows(), but this is the best option for identity() function, because after enlarging small GUI window, identify function has problems, hard to hit the points, same problem when using dev.new(), because only new window is created when graph was produced before

problem with ELEFAN score_mat in version1.6.2

Hi,

I am trying to run the tutorial "Single-species fish stock assessment with TropFishR" with version 1.6.2. ELEFAN function is not returning score_mat. This is how it looks like

res_RSA <- ELEFAN(synLFQ7a, Linf_range = seq(119,139,1), MA = 5,
                   K_range = seq(0.01,2,0.1), addl.sqrt = TRUE,
                   hide.progressbar = TRUE, contour=5)

# find 3 highest score values
n <- length(res_RSA$score_mat)
n

I get:
[1] 0

Later ,I installed version 1.2 from CRAN archive and got everything to work fine. Do you know why this may be?

Thanks!

VBGF add na.rm=F default

Dear Tobias,

Do you think it would be possible to add a na.rm parameter to VBGF, defaulting to FALSE like max() does (for example)? This would avoid having to code VBGF calls in an if/else wrapper to deal with NAs when running VBGF on a vector with NAs.

Thanks!

propagate problems

warning regarding memory.limit() might be connected to use of propagate which uses package ff
propagate::predictNLS currently omitted.
find solution

Cannot install the dev2.0 version

Good afternoon, I am trying to install the dev2.0 version of TropFishR, but the installed version is 1.6.0.

> devtools::install_github('tokami/TropFishR', ref= "dev2.0")
Downloading GitHub repo tokami/[email protected]
✔  checking for file ‘/tmp/RtmpyUxKuq/remotes2d092447bcbe/tokami-TropFishR-50fdbae/DESCRIPTION’ ...
─  preparing ‘TropFishR’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘TropFishR_1.6.0.tar.gz’

I removed the previous version before trying to install the dev2.0: remove.packages("TropFishR", lib="~/R/x86_64-pc-linux-gnu-library/3.5")

> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Manjaro Linux

VPA()

add terminal F and M values on the plot?

improve VPA

  • check following code as it excludes the last classes which are NA in catch due to too less years sampled
lastLengthClass <- max(which(!is.na(catch_cor)),na.rm=TRUE)  
  • make step for old algorithm choosable ?
  • make start of diag() and thus the start of real cohort choosable? or fix it as the first age class in the first column?
  • add option to create plus group, e.g.: plus.group = 6 or plus.group = 54 for age and length, respectively
  • add option to choose if terminal F should be displayed
  • add multi species VPA (Sparre 1991)

No $score_mat in the result of response surface analysis

Good afternoon, it's me again.

I followed your tutorial here, and you presented the code:

# find 3 highest score values
n <- length(res_RSA$score_mat)
best_scores <- sort(res_RSA$score_mat,partial=n-0:2)[n-0:2]
ind <- arrayInd(which(res_RSA$score_mat %in% best_scores),
                dim(res_RSA$score_mat))
Ks <- as.numeric(rownames(res_RSA$score_mat)[ind[,1]])
Linfs <- as.numeric(colnames(res_RSA$score_mat)[ind[,2]])

...

But when I entered the first line, and I looked in my environment, n is 0L.
I inspected res_RSA and score_mat is not present.

res_rsa

I am currently using TropFishR 1.6.0 under Linux Mint 18.3 with R version 3.4.4 (2018-03-15).

Error in seq.default(val_first, val_last) for the lfqRestructure() function

I am following your tutorial here. The data I used can be found here.

Here's what I did:

library(TropFishR)

lfq1 <- read.csv("lfq-data.csv")

dates <- colnames(lfq1)[-1]
dates <- strsplit(dates, "X")
dates <- unlist(lapply(dates, function(x) x[2]))
dates <- as.Date(dates, "%Y.%m.%d") # I changed this part to follow the format of dates in my data

lfq1new <- list(dates = dates,
                midLengths = lfq1$midlength,
                catch = as.matrix(lfq1[,-1]))

class(lfq1new) <- "lfq"

plot(lfq1new, Fname = "catch")

set.seed(1)

lfq1a <- lfqModify(lfq1new, bin_size = 4)

lfqbin <- lfqRestructure(lfq1a, MA = 5, addl.sqrt = FALSE)

But the last code throws an error:

Error in seq.default(val_first, val_last) : 
  'from' must be a finite number
In addition: Warning messages:
1: In min(which(lfq$catch[, i] != 0)) :
  no non-missing arguments to min; returning Inf
2: In max(which(lfq$catch[, i] != 0)) :
  no non-missing arguments to max; returning -Inf

What should I do? At first I thought that maybe the data arrangement is wrong, but I am pretty sure that it is correct, since I followed the tutorial given in the link above (the data follows the "Data arrangement 3").

predict_mod()

function to be used for the biomass per recruit calculation with selection ogive other than knife edge. Implemented approach returns negative values...

Plotting raw catch frequencies

Hi. Firstly thanks for the package!
I am new on R and also TropFishR. I am trying to arrange my data to plot raw catch frequencies. Here is the code I wrote. When run it I get the error message below. What am I missing?

library(TropFishR)

sample.no <- seq(1,9)
dates <- as.Date(c("2017-06-21","2017-07-25","2017-08-22","2017-09-26"))
midLengths <- seq(3.5,11.5,1)
catch <- c(
        ## 2017-06-21
        0,12,15,0,0,0,0,0,0,  
        ## 2017-07-25
        0,0,11,13,4,0,0,0,1,
        ## 2017-08-22
        0,0,0,0,14,12,6,0,0,
        ## 2017-09-26
        0,0,3,3,6,15,9,0,0)
  
catch <- matrix(catch,9,4)
colnames(catch) <- c(17.4166667,17.5,17.5833333,17.6666667)

sc <- list(sample.no,midLengths,dates,catch)
names(sc)<- c("sample.no","midLengths","dates","catch")
attr(sc,"catch")="lfq"
plot(sc, Fname = "catch")
Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' is a list, but does not have components 'x' and 'y'

necessary option for GillnetSelect.R

option required for GillnetSelect.R to manually exclude data points with low number of observations from analysis.
idea: identify() from plot with data points + info about number of observations
alternative: threshold number, everything below is excluded

QAICc for select_Millar

check + include

QAICc <- function(mod){
  ll <- as.numeric(mod$value) 
  K <- length(mod$estimates[,1])   
  n <- nnzero(CatchPerNet_mat) 
  c_hat = as.numeric(mod$out[4]/mod$out[6])
  qaicc = -2*ll/c_hat + 2*K + 2*K*(K + 1)/(n - K - 1)
  qaicc
}

Error in catchCurve(Mydatab, reg_int = c(6, 18), calc_ogive = TRUE) :

Dear Tobias Mildenberger,
I am having some trobles running "catchCurve" function.
synLFQ7b <- lfqModify(Mydata, vectorise_catch = TRUE, plus_group = 118)

run catch curve

res_cc <- catchCurve(Mydatab, reg_int = c(6,18), calc_ogive = TRUE)###出错了
Error in catchCurve(Mydatab, reg_int = c(6, 18), calc_ogive = TRUE) :
The catch curve with constant time interval is not applicable to length-frequency data. Please provide a catch vector.

plotLBB.data(lfq)

Dear Sir,
I'm trying to use the "A manual for the length-based Bayesian biomass estimator within TropFishR"
I follow the steps in the vignettes, but when I reach the "plotLBB.data(lfq)" I get error mesage:

> remotes::install_github("tokami/TropFishR")
Downloading GitHub repo tokami/TropFishR@HEAD
Running `R CMD build`...
* checking for file 'C:\Users\asamw\AppData\Local\Temp\RtmpuoSXW2\remotes1a208bc25be\tokami-TropFishR-4f0a13f/DESCRIPTION' ... OK
* preparing 'TropFishR':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'TropFishR_1.6.3.tar.gz'
Installing package into ‘C:/Users/asamw/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
* installing *source* package 'TropFishR' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (TropFishR)
> library(TropFishR)
> ## load data set into R environment
> data("synLFQ8")
> ## plot length-frequency data
> plot(synLFQ8, Fname = "catch")
> ## aggregate lfq data per year
> lfq <- lfqModify(synLFQ8, aggregate = "year")
> ## plot lfq data in standard TropFishR manner
> plot(lfq, Fname = "catch")
> ## plot data in LBB manner
> plotLBB.data(lfq)
Error in plotLBB.data(lfq) : could not find function "plotLBB.data"

Please help me with this issue as I'm intending to use this method in my data analysis.
Thanks
Issam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.