forestgeo / fgeo.biomass

Calculate biomass with allometric equations from the allodb package and ForestGEO data
https://forestgeo.github.io/fgeo.biomass
GNU General Public License v3.0
8 stars 4 forks source link

Ensure that allo_find() matches equations by site (not only species) #8

Closed maurolepore closed 5 years ago

maurolepore commented 5 years ago

@teixeirak and @gonzalezeb,

Here I confirm that the allo_find() joins census data with equations data by both species and site -- not just species (relevant source code; notice Notice this: by = c("sp", "site")).

Notice that allo_find() outputs not site other than "scbi":

library(tidyverse)
library(fgeo.biomass)

census <- fgeo.biomass::scbi_tree1
species <- fgeo.biomass::scbi_species

census_species <- census %>%
  add_species(species, "scbi")

result <- fgeo.biomass::scbi_tree1 %>%
  add_species(species, site = "scbi") %>%
  allo_find()

# The result has equations of multiple types
result
#> # A tibble: 5 x 2
#>   eqn_type       data                 
#>   <chr>          <list>               
#> 1 species        <tibble [8,930 x 8]> 
#> 2 genus          <tibble [5,642 x 8]> 
#> 3 mixed_hardwood <tibble [5,516 x 8]> 
#> 4 family         <tibble [10,141 x 8]>
#> 5 woody_species  <tibble [0 x 8]>

# But they all come from SCBI
result %>%
  unnest() %>%
  pull(site) %>%
  unique()
#> [1] "scbi"

Created on 2019-02-28 by the reprex package (v0.2.1)

maurolepore commented 5 years ago

Reopening to make it more visible to reviewers.

maurolepore commented 5 years ago

@teixeirak or @gonzalezeb, can you please review and discuss or close?

maurolepore commented 5 years ago

I'll call it done.