Closed dfifield closed 4 years ago
Hi Dave,
Happy New Year to you too!
Thank you very much for your kind words and the incredibly detailed bug report! This is fantastic, and I am glad you're finding the package useful.
I have released a new patch (v1.0.1) that implements your fixes above.
Much appreciated. Best, Phil
Hi and Happy New Year!
Thanks for the great package - it's really helpful! I had started to cobble something much cruder together and so I was delighted when I found
dsmextra
!I think I have found a couple of simple bugs. Apologies for not providing a complete reprex below, but I wasn't able to quickly pare down my segdata (327 rows) and predgrid (9124 rows) to make a minimal example that still displayed the behaviour in question.
1.
Apply()
sometimes returns the wrong type of structureThere are cases where
apply()
can return either a vector or matrix even though it was passed a dataframe, which messes up subsequent code.There are two places in
summarise_extrapolation.R
whereapply()
is used to convert each column of a dataframe tocharacter
:resdf <- apply(resdf, 2, function(x) as.character(x))
, andmic_resdf <- apply(mic_resdf, 2, function(x) as.character(x))
I have an example use case where
apply()
returns either a character vector or a 2-D character matrix on one of these rows instead of a dataframe, which messes up subsequent code that expectsresdf
ormic_resdf
to be a dataframe.For example, executing the following code where
'sst.sc'
has no univariate or combinatorial extrapolation:causes the following output:
In this particular case, it fails at line 329 because
apply()
(at line 327) has returned a character vector and thusmic_resdf
is no longer a dataframe at line 329.Changing these two lines to use
purrr::map_dfr()
instead ofapply()
fixed the problem for me:line 144:
resdf <- purrr::map_dfr(resdf, as.character)
and line 327:mic_resdf <- purrr::map_dfr(mic_resdf, as.character)
2.
max.univariate
misspelled asmax.univariates
There are four places in
compare_covariates.R
(on lines 245 and 250) wheremax.univariates
is used, but I think you intended it to bemax.univariate
?Line 245:
min.univariate <- c(min.univariate, rep("-", times = length(max.univariates)-length(min.univariate)))
Line 250:
max.univariates <- c(max.univariates, rep("-", times = length(min.univariate)-length(max.univariates)))
In my use case, executing the following:
causes the following error:
Changing
max.univariates
tomax.univariate
on these two lines fixed the problem for me.Thanks! Dave