Warnings introduced by R 4.0 update
Closed this issue · 1 comments
After updating to R 4.0, post_summ()
(and other functions) return a warning about condition having length > 1 and only the first element will be used. This issue occurs on postpack version 0.2.3 (at least).
data(cjs, package = "postpack")
post_summ(cjs, "b")
Returns the output as expected, but also throws these warnings:
Warning messages:
1: In if (class(post_mat) == "numeric") { :
the condition has length > 1 and only the first element will be used
2: In if (class(post_mat_sub) == "numeric") { :
the condition has length > 1 and only the first element will be used
3: In if (class(post_mat_sub) == "numeric") { :
the condition has length > 1 and only the first element will be used
After further digging, I've discovered that this is a result of the class()
function call, which originates in matrix2mcmclist()
. Evidently, now when you run:
m = matrix(c(1,1,1,1), 2, 2)
class(m)
You will get "matrix" "array"
. When this result is passed to if()
, it will produce the warnings above. This behavior is documented in the R 4.0.0 release notes under "Significant User-Visible Changes" (bullet 2).
This will take a little bit of fixing to make sure the if()
statements only respond to one logical element throughout all functions.