@@ -168,6 +168,10 @@ getFeedingLevel <- function(object, n, n_pp, n_other,
168
168
# ' @param params A MizerParams object
169
169
# ' @return A matrix (species x size) with the critical feeding level
170
170
# ' @export
171
+ # ' @examples
172
+ # ' \donttest{
173
+ # ' str(getFeedingLevel(NS_params))
174
+ # ' }
171
175
getCriticalFeedingLevel <- function (params ) {
172
176
params <- validParams(params )
173
177
params @ metab / params @ intake_max / params @ species_params $ alpha
@@ -195,8 +199,10 @@ getCriticalFeedingLevel <- function(params) {
195
199
# ' # Project with constant fishing effort for all gears for 20 time steps
196
200
# ' sim <- project(params, t_max = 20, effort = 0.5)
197
201
# ' # Get the energy at a particular time step
198
- # ' getEReproAndGrowth(params, n = N(sim)[15, , ],
199
- # ' n_pp = NResource(sim)[15, ], t = 15)
202
+ # ' e <- getEReproAndGrowth(params, n = N(sim)[15, , ],
203
+ # ' n_pp = NResource(sim)[15, ], t = 15)
204
+ # ' # Rate at this time for Sprat of size 2g
205
+ # ' e["Sprat", "2"]
200
206
# ' }
201
207
getEReproAndGrowth <- function (params , n = initialN(params ),
202
208
n_pp = initialNResource(params ),
@@ -233,10 +239,14 @@ getEReproAndGrowth <- function(params, n = initialN(params),
233
239
# ' @examples
234
240
# ' \donttest{
235
241
# ' params <- NS_params
242
+ # ' # Predation rate in initial state
243
+ # ' pred_rate <- getPredRate(params)
244
+ # ' str(pred_rate)
236
245
# ' # With constant fishing effort for all gears for 20 time steps
237
246
# ' sim <- project(params, t_max = 20, effort = 0.5)
238
247
# ' # Get the feeding level at one time step
239
- # ' getPredRate(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ])
248
+ # ' pred_rate <- getPredRate(params, n = N(sim)[15, , ],
249
+ # ' n_pp = NResource(sim)[15, ], t = 15)
240
250
# ' }
241
251
getPredRate <- function (params , n = initialN(params ),
242
252
n_pp = initialNResource(params ),
@@ -276,14 +286,18 @@ getPredRate <- function(params, n = initialN(params),
276
286
# ' @examples
277
287
# ' \donttest{
278
288
# ' params <- NS_params
289
+ # ' # Predation mortality in initial state
290
+ # ' M2 <- getPredMort(params)
291
+ # ' str(M2)
279
292
# ' # With constant fishing effort for all gears for 20 time steps
280
293
# ' sim <- project(params, t_max = 20, effort = 0.5)
281
294
# ' # Get predation mortality at one time step
282
- # ' getPredMort(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ])
295
+ # ' M2 <- getPredMort(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ])
283
296
# ' # Get predation mortality at all saved time steps
284
- # ' getPredMort(sim)
297
+ # ' M2 <- getPredMort(sim)
298
+ # ' str(M2)
285
299
# ' # Get predation mortality over the years 15 - 20
286
- # ' getPredMort(sim, time_range = c(15, 20))
300
+ # ' M2 <- getPredMort(sim, time_range = c(15, 20))
287
301
# ' }
288
302
getPredMort <- function (object , n , n_pp , n_other ,
289
303
time_range , drop = TRUE , ... ) {
@@ -416,24 +430,25 @@ getM2Background <- getResourceMort
416
430
# ' @examples
417
431
# ' \donttest{
418
432
# ' params <-NS_params
419
- # ' # Get the fishing mortality when effort is constant
420
- # ' # for all gears and time:
421
- # ' getFMortGear(params, effort = 1 )
422
- # ' # Get the fishing mortality when effort is different
423
- # ' # between the four gears but constant in time :
424
- # ' getFMortGear(params, effort = c(0.5, 1, 1.5, 0.75))
433
+ # ' # Get the fishing mortality in initial state
434
+ # ' F <- getFMortGear(params, effort = 1)
435
+ # ' str(F )
436
+ # ' # Get the initial fishing mortality when effort is different
437
+ # ' # between the four gears:
438
+ # ' F <- getFMortGear(params, effort = c(0.5, 1, 1.5, 0.75))
425
439
# ' # Get the fishing mortality when effort is different
426
440
# ' # between the four gears and changes with time:
427
441
# ' effort <- array(NA, dim = c(20, 4))
428
442
# ' effort[, 1] <- seq(from=0, to = 1, length = 20)
429
443
# ' effort[, 2] <- seq(from=1, to = 0.5, length = 20)
430
444
# ' effort[, 3] <- seq(from=1, to = 2, length = 20)
431
445
# ' effort[, 4] <- seq(from=2, to = 1, length = 20)
432
- # ' getFMortGear(params, effort = effort)
446
+ # ' F <- getFMortGear(params, effort = effort)
447
+ # ' str(F)
433
448
# ' # Get the fishing mortality using the effort already held in a MizerSim object.
434
449
# ' sim <- project(params, t_max = 20, effort = 0.5)
435
- # ' getFMortGear(sim)
436
- # ' getFMortGear(sim, time_range = c(10, 20))
450
+ # ' F <- getFMortGear(sim)
451
+ # ' F <- getFMortGear(sim, time_range = c(10, 20))
437
452
# ' }
438
453
# '
439
454
getFMortGear <- function (object , effort , time_range ) {
@@ -532,25 +547,26 @@ getFMortGear <- function(object, effort, time_range) {
532
547
# ' @examples
533
548
# ' \donttest{
534
549
# ' params <- NS_params
535
- # ' # Get the total fishing mortality when effort is constant for all
536
- # ' # gears and time:
537
- # ' getFMort(params, effort = 1 )
538
- # ' # Get the total fishing mortality when effort is different
539
- # ' # between the four gears but constant in time :
540
- # ' getFMort(params, effort = c(0.5,1,1.5,0.75))
550
+ # ' # Get the total fishing mortality in the initial state
551
+ # ' F <- getFMort(params, effort = 1)
552
+ # ' str(F )
553
+ # ' # Get the initial total fishing mortality when effort is different
554
+ # ' # between the four gears:
555
+ # ' F <- getFMort(params, effort = c(0.5,1,1.5,0.75))
541
556
# ' # Get the total fishing mortality when effort is different
542
557
# ' # between the four gears and changes with time:
543
558
# ' effort <- array(NA, dim = c(20,4))
544
559
# ' effort[, 1] <- seq(from = 0, to = 1, length = 20)
545
560
# ' effort[, 2] <- seq(from = 1, to = 0.5, length = 20)
546
561
# ' effort[, 3] <- seq(from = 1, to = 2, length = 20)
547
562
# ' effort[, 4] <- seq(from = 2, to = 1, length = 20)
548
- # ' getFMort(params, effort = effort)
563
+ # ' F <- getFMort(params, effort = effort)
564
+ # ' str(F)
549
565
# ' # Get the total fishing mortality using the effort already held in a
550
566
# ' # MizerSim object.
551
567
# ' sim <- project(params, t_max = 20, effort = 0.5)
552
- # ' getFMort(sim)
553
- # ' getFMort(sim, time_range = c(10, 20))
568
+ # ' F <- getFMort(sim)
569
+ # ' F <- getFMort(sim, time_range = c(10, 20))
554
570
# ' }
555
571
getFMort <- function (object , effort , time_range , drop = TRUE ) {
556
572
if (is(object , " MizerParams" )) {
@@ -665,8 +681,10 @@ getFMort <- function(object, effort, time_range, drop = TRUE) {
665
681
# ' # Project with constant fishing effort for all gears for 20 time steps
666
682
# ' sim <- project(params, t_max = 20, effort = 0.5)
667
683
# ' # Get the total mortality at a particular time step
668
- # ' getMort(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ],
669
- # ' t = 15, effort = 0.5)
684
+ # ' mort <- getMort(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ],
685
+ # ' t = 15, effort = 0.5)
686
+ # ' # Mortality rate at this time for Sprat of size 2g
687
+ # ' mort["Sprat", "2"]
670
688
# ' }
671
689
getMort <- function (params ,
672
690
n = initialN(params ),
@@ -718,8 +736,10 @@ getZ <- getMort
718
736
# ' params <- NS_params
719
737
# ' # Project with constant fishing effort for all gears for 20 time steps
720
738
# ' sim <- project(params, t_max = 20, effort = 0.5)
721
- # ' # Get the energy at a particular time step
722
- # ' getERepro(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ], t = 15)
739
+ # ' # Get the rate at a particular time step
740
+ # ' erepro <- getERepro(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ], t = 15)
741
+ # ' # Rate at this time for Sprat of size 2g
742
+ # ' erepro["Sprat", "2"]
723
743
# ' }
724
744
getERepro <- function (params , n = initialN(params ),
725
745
n_pp = initialNResource(params ),
@@ -763,7 +783,9 @@ getESpawning <- getERepro
763
783
# ' # Project with constant fishing effort for all gears for 20 time steps
764
784
# ' sim <- project(params, t_max = 20, effort = 0.5)
765
785
# ' # Get the energy at a particular time step
766
- # ' getEGrowth(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ], t = 15)
786
+ # ' growth <- getEGrowth(params, n = N(sim)[15, , ], n_pp = NResource(sim)[15, ], t = 15)
787
+ # ' # Growth rate at this time for Sprat of size 2g
788
+ # ' growth["Sprat", "2"]
767
789
# ' }
768
790
getEGrowth <- function (params , n = initialN(params ),
769
791
n_pp = initialNResource(params ),
0 commit comments