Skip to content

Commit

Permalink
Add gh-actions to automate rendering readme, update readme, update si…
Browse files Browse the repository at this point in the history
…mdata script
  • Loading branch information
shaunporwal committed Jan 7, 2025
1 parent bb7910a commit b22f333
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/render-readme.yaml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 2 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
<!-- badges: end -->

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

Expand Down Expand Up @@ -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: <https://github.com/r-lib/actions/tree/v1/examples>.

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: <https://github.com/r-lib/actions/tree/v1/examples>.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
<!-- badges: start -->
<!-- badges: end -->

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

Expand Down Expand Up @@ -56,9 +52,5 @@ use GitHub Actions to re-render `README.Rmd` every time you push. An
example workflow can be found here:
<https://github.com/r-lib/actions/tree/v1/examples>.

You can also embed plots, for example:

<img src="man/figures/README-pressure-1.png" width="100%" />

In that case, don’t forget to commit and push the resulting figure
files, so they display on GitHub and CRAN.
18 changes: 9 additions & 9 deletions data-raw/trial.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
) |>
Expand All @@ -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"))

0 comments on commit b22f333

Please sign in to comment.