Skip to content

Instantly share code, notes, and snippets.

View hdbt's full-sized avatar
🎯
Focusing

hdbt

🎯
Focusing
View GitHub Profile
@hdbt
hdbt / align_d.R
Last active November 13, 2023 10:02
align decimal points according to model length (modelsummary helper function)
# function to add the right amount of d for align argument of modelsummary according to models
align_d <- function(models) rep("d", length(models)) |> c("l", ... = _) |> paste0(collapse = "")
@hdbt
hdbt / print.kableExtra.R
Created February 9, 2023 10:23
Workaround for kableExtra HTML View in RNotebook
print.kableExtra <- function (x, ...) {
view_html <- getOption("kableExtra_view_html", TRUE)
if (view_html & interactive()) {
dep <- list(
rmarkdown::html_dependency_jquery(),
rmarkdown::html_dependency_bootstrap(theme = "cosmo"),
kableExtra::html_dependency_kePrint(),
kableExtra::html_dependency_lightable()
)
@hdbt
hdbt / corstars1.R
Last active November 13, 2023 10:03
Correlation Matrix
corstarsl <- function(xx){
require(Hmisc)
x <- as.matrix(xx)
R <- rcorr(x)$r
p <- rcorr(x)$P
## define notions for significance levels; spacing is important.
mystars <- ifelse(p < .001, "***", ifelse(p < .01, "** ", ifelse(p < .05, "* ", " ")))
## trunctuate the matrix that holds the correlations to two decimal
@hdbt
hdbt / gist:4989c678c683bc78c3596cdb8587930c
Created August 20, 2021 12:40
Give rights to everybody on directory
sudo chmod -R 757 /var/log/shiny-server/