pierucci / heemod

:chart_with_upwards_trend:Markov Models for Health Economic Evaluations
https://pierucci.org/heemod/
Other
41 stars 25 forks source link

look_up warning message mistakes #341

Closed jriley-dhsc closed 4 years ago

jriley-dhsc commented 4 years ago

The look_up documentation has the following example:

tempdf <- expand.grid(arg1 = c("A", "B", "C"), arg2 = 1:4, arg3 = 1:5)
tempdf$value <- 1:60

look_up(
  data = tempdf,
  value = "value",
  arg1 = c("A", "B", "C", "B", "A"),
  arg2 = c(1, 1, 3.2, 3.0, 5), 
  arg3 = c(-1, 1, 1, 2, 3)
)

Which returns:

[1] NA  2 NA 20 NA
Warning message:
In look_up(data = tempdf, value = "value", arg1 = c("A", "B", "C",  :
  Some values were not found, returning missing data:
arguments to look_up: arg1 = A, arg2 = B, arg3 = C, arg1 = B, arg2 = A, arg3 = 1, arg1 = 1, arg2 = 3.2, arg3 = 3, arg1 = 5, arg2 = -1, arg3 = 1, arg1 = 1, arg2 = 2, arg3 = 3, value = value

Which isn't right - arg2 = B was never fed to look_up.

Worse, B wasn't one of the bad values for arg1!


tempdf <- expand.grid(arg1 = c("A", "B", "C"), arg2 = 1:4, arg3 = 1:5)
tempdf$value <- 1:60

tibble(
    arg1 = c("A", "B", "C", "B", "A"),
    arg2 = c(1, 1, 3.2, 3.0, 5), 
    arg3 = c(-1, 1, 1, 2, 3)
) %>% 
    anti_join(tempdf) %>% 
    knitr::kable()
arg1 arg2 arg3
A 1.0 -1
C 3.2 1
A 5.0 3
KZARCA commented 4 years ago

Thanks, you're right, the warning is not very informative! Would you make a pull request?