metrumresearchgroup / pmtables

TeX tables for pharmacometrics.
https://metrumresearchgroup.github.io/pmt-book
11 stars 1 forks source link

yaml ` Can't combine `..1$abb` <character> and `..5$abb` <logical>.` #340

Open KatherineKayMRG opened 3 months ago

KatherineKayMRG commented 3 months ago

I included the following in a glossary yaml

OBS:
  abb: OBS
  def: observations above the LLOQ
nEDA:
  abb: n
  def: number of subjects summarized
SD: 
  abb: SD
  def: standard deviation

when trying to run glo <- read_glossary(here("report/glossary.yaml")) I got an error

glo <- read_glossary(here("report/glossary.yaml"))
Error in `read_yaml_glossary()` at pmtables/R/glossary.R:75:5:
! Failed to parse glossary file; see ?yaml_as_df() for help formatting this file.
• Error in dplyr::bind_rows(res, .id = .id) : 
  Can't combine `..1$abb` <character> and `..5$abb` <logical>.
Run `rlang::last_trace()` to see where the error occurred.

It was fixed with

OBS:
  abb: OBS
  def: observations above the LLOQ
nEDA:
  abb: "n"
  def: number of subjects summarized
SD: 
  abb: SD
  def: standard deviation

Is this expected behaviour? Is there anything we can do? It's such an unhelpful error message

kylebaron commented 3 months ago

It's expected, sort of. yaml sees a bare n and it interprets that as "no", turning abb into a logical value. When you write "n", you're telling the parser that you mean this to be a character value.

You'll see the same error if you call

df <- yaml_as_df(here("report/glossary.yaml"))

We could document this better, but don't know how helpful that would be in the wild. Maybe some other stuff we could do help when this happens, but I don't think there is any way to write bare n and not have yaml turn that into FALSE.

KatherineKayMRG commented 3 months ago

Ah ok, sorry I didn't make the connection between n > no > FALSE for yaml. I'm not sure where to suggest documenting it but I guess it might not be important often?

Thanks for following up