NewGraphEnvironment / fish_passage_bulkley_2020_reporting

https://newgraphenvironment.github.io/fish_passage_bulkley_2020_reporting/
Apache License 2.0
1 stars 2 forks source link

`tab_fish_dense()` replace NA error #42

Closed lucy-schick closed 6 days ago

lucy-schick commented 1 month ago

Getting the following error when calling tab_fish_dense(). Issue is arising b/c mutate_all(~replace_na(.,"0")) is trying to replace columns of type double with a string "0" I think. I belived this worked before but it sounds like replace_NA was updated in tidyr 1.2.0 so things have changes, more info here https://stackoverflow.com/questions/71227130/replace-na-of-numeric-columns-with-both-numeric-and-character-values-in-r.

Quitting from lines  at lines 1700-1704 [tab-fish-dens-58159] (Bulkley.Rmd)
Error in `mutate()`:
ℹ In argument: `Fry = (structure(function (..., .x = ..1, .y = ..2, . = ..1) ...`.
Caused by error in `vec_assign()`:
! Can't convert `replace` <character> to match type of `data` <double>.
Backtrace:
  1. tab_fish_dens() %>% my_kable(caption_text = my_caption)
 20. tidyr:::replace_na.default(., "0")
 21. vctrs::vec_assign(data, missing, replace, x_arg = "data", value_arg = "replace")

probably an easy fix. will look into it on tuesday.

NewGraphEnvironment commented 1 month ago

guessing we may run into issues like double headers and black text in night mode once this thing builds so I think the message linked below still applies as a value first attempt to deal with errors

https://github.com/NewGraphEnvironment/fish_passage_bulkley_2020_reporting/issues/41#issuecomment-2118364439

NewGraphEnvironment commented 1 month ago

FYI - replacing na in kables is dealt with since 2021 in the index.Rmd setup chunk

We need to avoid rewriting this entire repo as that will likely take 100s of hours but good to understand current workflows vs past

https://github.com/NewGraphEnvironment/mybookdown-template/blob/857011bb9729dd8c01c26b1b57904a88533c735c/index.Rmd#L54

lucy-schick commented 1 month ago

mmm okay. That line is already present in index.rmdand still getting the same error...

lucy-schick commented 1 month ago

removed call to mutate_all and all works good. NAs are taken care of in index.rmd as mentioned above.