From b22f333500125194a77db2ad94de9a7d6c2c4539 Mon Sep 17 00:00:00 2001 From: Shaun Porwal Date: Mon, 6 Jan 2025 22:29:01 -0500 Subject: [PATCH] Add gh-actions to automate rendering readme, update readme, update simdata script --- .github/workflows/render-readme.yaml | 32 ++++++++++++++++++++++++++++ README.Rmd | 12 ++--------- README.md | 10 +-------- data-raw/trial.R | 18 ++++++++-------- 4 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/render-readme.yaml diff --git a/.github/workflows/render-readme.yaml b/.github/workflows/render-readme.yaml new file mode 100644 index 0000000..20a5dfe --- /dev/null +++ b/.github/workflows/render-readme.yaml @@ -0,0 +1,32 @@ +on: + push: + paths: + - 'README.Rmd' + - '*.yaml' + +name: Render README + +jobs: + render: + name: Render README + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GENERAL_PAT }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v1 + - name: Install rmarkdown, remotes, and the local package + run: | + install.packages("remotes") + remotes::install_local(".") + remotes::install_cran("rmarkdown") + shell: Rscript {0} + - name: Render README + run: Rscript -e 'rmarkdown::render("README.Rmd")' + - name: Commit results + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + git commit README.md -m 'Re-build README.Rmd' || echo "No changes to commit" + git push origin || echo "No changes to commit" diff --git a/README.Rmd b/README.Rmd index b243605..8e171c7 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,7 +18,7 @@ knitr::opts_chunk$set( -The goal of islet is to help establish secure data pipelines for data cleaning and analytics, designed for teams analyzing patient outcome data. With Islet, you can easily clean and process sensitive patient data, while generating reports that track data irregularities and issues. +Islet contains personal R functions. I'm also using this to learn how to create R packages. ## Installation @@ -53,12 +53,4 @@ islet::make_banner(str_to_banner = 'analyze column from dataframe', ``` -You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. You could also use GitHub Actions to re-render `README.Rmd` every time you push. An example workflow can be found here: . - -You can also embed plots, for example: - -```{r pressure, echo = FALSE} -plot(pressure) -``` - -In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN. +You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. You could also use GitHub Actions to re-render `README.Rmd` every time you push. An example workflow can be found here: . \ No newline at end of file diff --git a/README.md b/README.md index ac3e896..949dcd3 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,7 @@ -The goal of islet is to help establish secure data pipelines for data -cleaning and analytics, designed for teams analyzing patient outcome -data. With Islet, you can easily clean and process sensitive patient -data, while generating reports that track data irregularities and -issues. +Personal R functions. ## Installation @@ -56,9 +52,5 @@ use GitHub Actions to re-render `README.Rmd` every time you push. An example workflow can be found here: . -You can also embed plots, for example: - - - In that case, don’t forget to commit and push the resulting figure files, so they display on GitHub and CRAN. diff --git a/data-raw/trial.R b/data-raw/trial.R index 0bf6534..3e6d597 100644 --- a/data-raw/trial.R +++ b/data-raw/trial.R @@ -19,25 +19,25 @@ trial <- response = runif(n) < response_prob, ttdeath_true = exp(1 + 0.2 * response + - -0.1 * as.numeric(stage) + - -0.1 * as.numeric(grade) + - rnorm(n, sd = 0.5)) * 12, + -0.1 * as.numeric(stage) + + -0.1 * as.numeric(grade) + + rnorm(n, sd = 0.5)) * 12, death = ifelse(ttdeath_true <= 24, 1L, 0L), ttdeath = pmin(ttdeath_true, 24) |> round(digits = 2), - + # New columns added below: visit_date = sample(seq.Date(as.Date("2020-01-01"), as.Date("2022-01-01"), by = "days"), n, replace = TRUE), # Date follow_up_date = sample(seq.Date(as.Date("2022-01-02"), as.Date("2024-01-01"), by = "days"), n, replace = TRUE), # Date - + has_side_effects = sample(c(TRUE, FALSE), n, replace = TRUE), # Logical enrolled_in_study = sample(c(TRUE, FALSE), n, replace = TRUE), # Logical - + bmi = round(rnorm(n, mean = 25, sd = 4), 1), # Numeric systolic_bp = round(rnorm(n, mean = 120, sd = 15)), # Numeric - + patient_id = paste0("ID-", sprintf("%03d", seq(1, n))), # Character hospital = sample(c("Hospital A", "Hospital B", "Hospital C"), n, replace = TRUE), # Character - + insurance = sample(c("Private", "Medicaid", "Medicare"), n, replace = TRUE) |> factor(), # Factor smoking_status = sample(c("Non-smoker", "Former smoker", "Current smoker"), n, replace = TRUE) |> factor() # Factor ) |> @@ -62,4 +62,4 @@ attr(trial$hospital, "label") <- "Hospital" attr(trial$insurance, "label") <- "Insurance Type" attr(trial$smoking_status, "label") <- "Smoking Status" -trial |> readr::write_csv(file = here::here('data/trial.csv')) +trial |> readr::write_csv(file = here::here("data/trial.csv"))