Skip to contents

Convert a flat data.frame with species names and species (supra-)category (e.g. family, order, endemism status, etc.) into a proper data.frame object that can then be used by other functions. The final output contains species in rows and two columns (species name and species category).

Usage

fb_format_species_categories(data, species, category)

Arguments

data

a data.frame in a long format (see example).

species

a character of length 1. Name of the column with species names.

category

a character of length 1. Name of the column with species category.

Value

A data.frame with species in rows and two columns (species name and species category).

Examples

library("funbiogeo")

filename <- system.file("extdata", "raw_mammals_data.csv", 
                        package = "funbiogeo")
all_data <- read.csv(filename)

head(all_data)
#>   species           order    site longitude latitude count adult_body_mass
#> 1  sp_001 Cetartiodactyla  fb_103  7.271821 59.09736     1        461900.8
#> 2  sp_001 Cetartiodactyla fb_1001 20.771821 52.59736     1        461900.8
#> 3  sp_001 Cetartiodactyla  fb_102  6.771821 59.09736     1        461900.8
#> 4  sp_001 Cetartiodactyla  fb_104  7.771821 59.09736     1        461900.8
#> 5  sp_001 Cetartiodactyla  fb_101  6.271821 59.09736     1        461900.8
#> 6  sp_001 Cetartiodactyla fb_1000 20.271821 52.59736     1        461900.8
#>   gestation_length litter_size max_longevity sexual_maturity_age diet_breadth
#> 1              235        1.25           324               668.2            1
#> 2              235        1.25           324               668.2            1
#> 3              235        1.25           324               668.2            1
#> 4              235        1.25           324               668.2            1
#> 5              235        1.25           324               668.2            1
#> 6              235        1.25           324               668.2            1

species_categories <- fb_format_species_categories(all_data, "species", 
                                                   "order")
species_categories[1:6, ]
#>    species           order
#> 1   sp_001 Cetartiodactyla
#> 8   sp_002        Rodentia
#> 11  sp_005        Rodentia
#> 27  sp_006        Rodentia
#> 59  sp_010      Chiroptera
#> 81  sp_013       Carnivora