Code
::shelf(
librarian/calcofi4r,
calcofi
dplyr, DT, glue, here, quiet = T)
source(here("../apps_dev/libs/db.R")) # con: database connection
While working on + larvae into oceano app · Issue #23 · CalCOFI/apps, noticing some funkiness with species_codes
and species_codes_new
tables.
::shelf(
librarian/calcofi4r,
calcofi
dplyr, DT, glue, here, quiet = T)
source(here("../apps_dev/libs/db.R")) # con: database connection
species_codes
<- tbl(con, "species_codes") |>
d_spp collect()
dim(d_spp)
[1] 1209 6
table(d_spp$taxon_rank, useNA="ifany")
Class Family Genus Infraclass Kingdom None Order
2 153 262 1 1 6 15
Phylum Species Subfamily Suborder Subphylum Subspecies
2 743 17 5 1 1
species_codes_new
<- tbl(con, "species_codes_new") |>
d_spp_new collect()
dim(d_spp_new)
[1] 1150 6
table(d_spp_new$taxon_rank, useNA="ifany")
Class Family Genus Infraclass Kingdom None Order
2 145 253 1 1 4 15
Phylum Species Subfamily Suborder Subphylum Subspecies <NA>
2 672 15 4 1 1 34
species_codes
vs species_codes_new
|>
d_spp left_join(d_spp_new, by="scientific_name") |>
filter(is.na(taxon_rank.x) | is.na(taxon_rank.y)) |>
# names() |> paste(collapse=', ') |> cat()
select(
scientific_name,
id.x, id.y,
spccode.x, spccode.y,
itis_tsn.x, itis_tsn.y,
common_name.x, common_name.y,|>
taxon_rank.x, taxon_rank.y) datatable()
is.na(taxon_rank)
(n=34) in species_codes_new
but not species_codes
?taxon_rank == 'None'
?species_codes_new
since missing taxon_rank
for 34 rows that are populated in species_codes
species_codes
to species
id
spccode
spccode
to sp_id
since