如何使用 kableExtra 作为 kable 的 `ifelse` 参数

How to use kableExtra as an `ifelse` argument with kable

我想将 kableExtra 命令作为 kable 的可选命令。在这种情况下,如果行数大于 1,我希望 footnote 是可选的。请参阅:

library(kableExtra)
ress2 <- structure(list(Constrate = c("RR - RX", "RR - XX", "RX - XX"), 
                        `Diferençe de Médias` = c(-0.96, -1.05, -0.09), 
                        `Erro Padrão` = c(0.63, 0.75, 0.63), 
                        `IC Inf (95%)` = c(-2.53, -2.92, -1.66), 
                        `IC Sup (95%)` = c(0.61, 0.82, 1.48), 
                        `Valor-p` = c(0.35, 0.43, 1)), 
                   row.names = c(NA,3L), class = "data.frame")
# It works
kable(ress2,
      align = c("l", rep("c", ncol(ress)-1))) %>%
  footnote(general = "d")

# What I have tried:
kable(ress2,
      align = c("l", rep("c", ncol(ress)-1))) %>% 
  { if(nrow(ress2)>1) add(., footnote(general = "d")) else .}

kable(ress2,
      align = c("l", rep("c", ncol(ress)-1))) %>% 
  { ifelse(nrow(ress2)>1,footnote(general = "d"),.) }
k <- kable(ress2, align = c("l", rep("c", ncol(ress)-1)))
if(nrow(ress2)>1) {
  k <- k %>% footnote(general = "d")
}
k