Skip to contents

This function can used to access or assign the species group labels contained within the sefraData object.

Usage

species_groups(object, ...)

# S4 method for class 'sefraData'
species_groups(object, print_species = FALSE)

species_groups(object, ...) <- value

# S4 method for class 'sefraData,character'
species_groups(object) <- value

# S4 method for class 'sefraData,data.frame'
species_groups(object) <- value

Arguments

object

a sefraData class object.

...

additional arguments to the generic function (not used)

print_species

logical indicating whether to print species associated with each species group.

value

a character vector of species group labels of equal length to the number of species. This may require some elements to be duplicated.

See also

See fishery_groups to access or assign fishery groups.

Examples

# input vector of species groups per species
dat <- sefraData(c('DIW', 'DQS', 'TWD'))
#> species codes input: including all species-dependent capture codes
#> constructed 'sefraData' object
species_groups(dat) <- c('group1', 'group1', 'group2')
#> Warning: assumption that vector of group names is ordered by species in object
species_groups(dat)
#> 2 species groups
#>   species_group id_species_group
#> 1        group1                1
#> 2        group2                2
# input data frame
dat <- sefraData(c('DIW', 'DQS', 'TWD'))
#> species codes input: including all species-dependent capture codes
#> constructed 'sefraData' object
species_groups(dat) <- data.frame(species = c('DQS', 'TWD', 'TWD', 'DIW'), 
   species_group = c('groupB', 'groupA', 'groupA', 'groupB'))
species_groups(dat)
#> 2 species groups
#>   species_group id_species_group
#> 1        groupB                1
#> 2        groupA                2