Upgrade to Pro — share decks privately, control downloads, hide ads and more …

R Not Only in Production

Kara Woo
September 20, 2023

R Not Only in Production

I will share what our team has learned from successfully integrating R in all areas of our company's operations. InsightRX is a precision medicine company whose goal is to ensure that each patient receives the right drug at the optimal dose. At InsightRX, R is a first-class language that's used for purposes ranging from customer-facing products to internal data infrastructure, new product prototypes, and regulatory reporting. Using R in this way has given us the opportunity to forge fruitful collaborations with other teams in which we can both learn and teach.

Kara Woo

September 20, 2023
Tweet

More Decks by Kara Woo

Other Decks in Technology

Transcript

  1. How can the strengths of R, and the people who

    use it, influence the organization as a whole?
  2. ETL

  3. • REST API • Data processing pipeline • Analyses and

    new models • Model validation • Regulatory reporting • New product prototypes • …
  4. { "firstName": "First name", "lastName": "Last name", "dob": "Date of

    birth", "changeMyPassword": "Change my password", "logout": "Logout", ... } { "firstName": "Vorname", "lastName": "Nachname", "dob": "Geburtsdatum", "changeMyPassword": "Ändere mein Passwort", "logout": "Ausloggen", ... }
  5. { "firstName": "First name", "lastName": "Last name", "dob": "Date of

    birth", "changeMyPassword": "Change my password", "logout": "Logout", ... }
  6. { "firstName": "First name", "lastName": "Last name", "dob": "Date of

    birth", "age": "Age", "changeMyPassword": "Change my password", "logout": "Logout", ... } 👀
  7. { "firstName": "First name", "lastName": "Last name", "dob": "Date of

    birth", "age": "Age", "changeMyPassword": "Change my password", "logout": "Logout", ... } { "firstName": "Vorname", "lastName": "Nachname", "dob": "Geburtsdatum", "changeMyPassword": "Ändere mein Passwort", "logout": "Ausloggen", ... } 👀
  8. { "firstName": "First name", "lastName": "Last name", "dob": "Date of

    birth", "age": "Age", "changeMyPassword": "Change my password", "logout": "Logout", ... } { "firstName": "Vorname", "lastName": "Nachname", "dob": "Geburtsdatum", "age": "Alter", "changeMyPassword": "Ändere mein Passwort", "logout": "Ausloggen", ... } 👀
  9. Elevated creatinine suggests kidney damage Easy, right? • Data gaps

    • Out of order data • Data in di ff erent units • Missing baseline • Non-numeric data • Data entry errors
  10. test_that("AKI stage is calculated correctly", { result <- calc_aki_stage( scr

    = c(0.7, 1.0), t = c(0, 24), egfr = c(60, 40) ) expect_equal(result$stage, "stage 1") })
  11. test_that("AKI stage is calculated correctly", { result <- calc_aki_stage( scr

    = c(0.7, 1.0), t = c(0, 24), egfr = c(60, 40) ) expect_equal(result$stage, "stage 1") })
  12. test_that("AKI stage is calculated correctly", { result <- calc_aki_stage( scr

    = c(0.7, 1.0), t = c(0, 24), egfr = c(60, 40) ) expect_equal(result$stage, "stage 1") })
  13. test_that("AKI stage is calculated correctly", { result <- calc_aki_stage( scr

    = c(0.7, 1.0), t = c(0, 24), egfr = c(60, 40) ) expect_equal(result$stage, "stage 1") })
  14. test_that("stage correct: 0.3 mg/dl rise", { # ... }) test_that("stage

    correct: 1.5x baseline rise", { # ... }) test_that("sorts times correctly", { # ... }) test_that("handles non-numeric inputs", { # ... }) test_that("handles only 1 observation", { # ... })
  15. 5d01863 Add function to detect AKI ✅ a28vf11 Rewrite AKI

    function to improve performance ❌ 682hcKa Fix handling of missing data ✅
  16. Continuous integration • Find bugs quickly • Be lazy free

    up time for more important work • Make sure the code continues to behave as intended
  17. FROM rstudio/plumber:v1.1.0 RUN Rscript -e "install.packages('clinPK')" COPY . /myproject WORKDIR

    /myproject ENTRYPOINT ["Rscript", "entrypoint.R"] Dockerfile https://github.com/karawoo/dockerdemo
  18. Database query was too slow Added an index to the

    database Data processing pipeline was too slow
  19. Database query was too slow Added an index to the

    database Data processing pipeline was too slow Removed the index
  20. Tests test_that("...", { # ... }) test_that("...", { # ...

    }) test_that("...", { # ... }) test_that("...", { # ... }) test_that("...", { # ... }) test_that("...", { # ... }) test_that("...", { # ... })
  21. Tests test_that("...", { # ... }) test_that("...", { # ...

    }) test_that("...", { # ... }) test_that("...", { # ... }) test_that("...", { # ... }) test_that("...", { # ... }) test_that("...", { # ... }) become data