Open ralmond opened 3 months ago
~I think kable and functions in this package only addresses 2d array. In my impression, this is probably true for most table generation packages. It probably makes more sense to use some plotting methods to complete this task.~
Sorry, I should have thought about it more carefully before throwing out comments. This feature is possible. Let me see what can be done here
The purpose of ftable
is to flatten the 3d array into a matrix (sort of like going from wide to long format using dplyr
.
I think that the problem is that ftable
is stored as some kind of ragged array. If manually do the step using rbind, it seems to work:
phi2 <- array(runif(50),c(5,5,2))
kableExtra::kbl(rbind(phi2[,,1],phi2[,,2]),digits=3,booktabs=T) |>
kableExtra::kable_classic_2() |>
kableExtra::pack_rows("Y=0",1,5) |>
kableExtra::pack_rows("Y=1",6,10)
This produces what I want, I just need to be a bit more manual about unrolling the array.
Also, kbl(ftable(array(runif(50),c(5,5,2)))
works, but kbl(ftable(array(runif(50),c(5,2,5)))
does not.
Finally, I'm realizing the problem is actually upstream in knitr::kable
. I should probably refile the bug upstream.
Describe the bug
I'm using
ftable
to render a 3d array, but when I pass the output offtable
tokbl
, I get an error about bad arguments to an internalsprintf
function.To Reproduce
Created on 2024-05-31 with reprex v2.1.0