Produces an object suitable to pass as the funcresp
to spec_rescomp()
.
funcresp_custom(func, spnum = NULL, resnum = NULL)
A function that takes resources
(a numeric vector of resource concentrations) and params
(a list of parameters) and returns a matrix of growth rates of each species on each resource.
The number of species; the number of rows in the matrix returned by func
.
The number of resources; the expected length of the resources
argument to func
and the number of columns in the matrix returned by func
.
S3 object of class rescomp_funcresp
.
If spnum
or resnum
are NULL, spec_rescomp()
will attempt to infer them.
This is fine if the result is passed directly to spec_rescomp()
, but may fail if the result must be combined with other rescomp_funcresp
s first.
# Type 1 functional response with fixed growth rates
funcresp_custom(
function(resources, params) {
growth_rates <- c(0.2, 0.3)
outer(growth_rates, resources)
},
spnum = 2
)
#> $func
#> function (resources, params)
#> {
#> growth_rates <- c(0.2, 0.3)
#> outer(growth_rates, resources)
#> }
#> <environment: 0x136b2bf38>
#>
#> $spnum
#> [1] 2
#>
#> $resnum
#> NULL
#>
#> attr(,"class")
#> [1] "rescomp_funcresp_custom" "rescomp_funcresp"