International-Soil-Radiocarbon-Database / ISRaD

Repository for the development and release of ISRaD data and tools
https://international-soil-radiocarbon-database.github.io/ISRaD/
24 stars 15 forks source link

ISRaD.rep.count.frc surpasses warning messages #223

Closed bpbond closed 4 years ago

bpbond commented 4 years ago

Currently ISRaD.rep.count.frc has a suppressWarnings() call around its join operations, because otherwise it generates:

Warning messages:
1: Column `pro_name` joining factors with different levels, coercing to character vector 
2: Column `lyr_name` joining factors with different levels, coercing to character vector 
3: Column `pro_name` joining character vector and factor, coercing into character vector 
4: Factor `frc_property` contains implicit NA, consider using `forcats::fct_explicit_na` 

This isn't great, because it might hide real warnings we want to see.

What's the correct thing to do here? Should the elements of database have been created with stringsAsFactors=FALSE originally? Or are those factors needed, and thus ISRaD.rep.count.frc should change them to character before joining?

jb388 commented 4 years ago

@bpbond we've fixed this in the past by wrapping any dplyr join calls with as.character, cf. ISRaD.flatten, ISRaD.extra.delta.delta, etc. I'll add that call to ISRaD.rep.count.frc. Seems like the easiest fix.

Note that "database" should have been created with stringsAsFactors=FALSE, but because not all studies have data in every table, there will always be different factor levels for the join by variables, e.g. "entry_name", "site_name", "pro_name".