View knitr_helpers.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from inline to yaml chunk options | |
knitr::convert_chunk_header() | |
# Verbatim engine for instruction | |
# https://bookdown.org/yihui/rmarkdown-cookbook/verbatim-code-chunks.html |
View read_fn_current.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Read current files | |
# Assumed file naming structure is Filename_YYYYMMDD.csv | |
# list of all files | |
fn_list_data_raw <- dir("data/") | |
# filenames to match | |
fn_dat_list_in <- | |
c( |
View Summary_tables_example.qmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Tables using `gtsummary` | |
subtitle: Example workflow for Table 1 (demographics), regression, contingency table, etc. | |
author: Erik Erhardt | |
date: last-modified # today, now, last-modified | |
date-format: long # full, long, medium, short, iso, https://quarto.org/docs/reference/dates.html | |
format: | |
html: | |
theme: litera | |
highlight-style: atom-one |
View erik_qmd_template_simple.qmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Title | |
subtitle: Subtitle | |
author: Erik Erhardt | |
date: last-modified # today, now, last-modified | |
date-format: long # full, long, medium, short, iso, https://quarto.org/docs/reference/dates.html | |
format: | |
html: | |
theme: litera | |
highlight-style: atom-one |
View erik_qmd_template.qmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Title | |
subtitle: Subtitle | |
description: | | |
A qmd quarto template document. | |
abstract: | | |
Document abstract may be somewhat long. | |
author: | |
- name: Erik Erhardt | |
url: https://StatAcumen.com/about |
View Programming with dplyr, dynamic variable names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://cran.r-project.org/web/packages/dplyr/vignettes/programming.html |
View Error capture and do
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example error capture | |
# First check if effect is involved in interactions | |
check_message <- | |
e_message_capture( | |
emmeans::emmeans( | |
object = fit | |
, specs = var_xs | |
) | |
)(1) |
View convert_character_to_factor.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iris_e <- iris | |
str(iris_e) | |
# from factor to character | |
iris_e <- iris_e %>% mutate(across(where(is.factor), as.character)) | |
str(iris_e) | |
# from character to factor | |
iris_e <- iris_e %>% mutate(across(where(is.character), as.factor)) | |
str(iris_e) | |
View e_table1_summaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r, results='asis'} | |
# list of column variables for table | |
list_var_col_names <- "Group" | |
list_var_col_labels <- "Group" | |
# list of row variables for table | |
list_var_row_names <- c(Var[["list"]][["var_resp"]] , Var[["list"]][["var_covar"]] ) | |
list_var_row_labels <- c(Var[["label"]][["var_resp"]], Var[["label"]][["var_covar"]]) | |
fn_root <- "./out/tab1_vars_dx_demo" |
View find_unicode.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[^\x00-\x7F] | |
To fix this, you have to find the Unicode and replace it with it’s ASCII equivalent. To do this: Ctrl-F to find, search for “[^\x00-\x7F]” (without quotes), select “Regex” for regular expressions, and find the “Next” one. |
NewerOlder