dm cheat sheet
Chat with Large Language Models
Chat with large language models from a range of providers including Claude, OpenAI, Azure, Bedrock, and Google Gemini. Supports streaming,a asyncronous calls, tool calling, and structured data extraction.
UNCHARTED DATA: Interactive Tooltip Tables
How to include tables in your {ggiraph} tooltips.
The most efficient way to manage snapshot tests in R.
Use CI and Github API
Snapshot testing gets difficult when there is more than one variant of the same result.
The reason why snapshot testing might be discouraging is due to the fact that snapshots will most likely fail due to environment settings. If one person runs the tests on a Mac and another on a Linux machine, the snapshots of rendered images will almost certainly be different. Comparing these snapshots will result in a failed test even though the code is correct.
Add CI to the mix, and you have a hot mess.
The easiest solution is to introduce variants.
Variants are versions of snapshots which were created on different environments.
In {testthat} variants are stored in separate directories. You can pass a name of the variant to the variant argument of testthat::test_snapshot. If you have a Linux, set variant = "linux", if you have a Mac, set variant = "mac".
Use snapshots generated on CI as the source of truth.
Don’t check in snapshots generated on your machine. Generate them on CI and download them to your machine instead.
Step 1: Archive snapshots on CI
Add this step to you CI testing workflow to allow downloading generated snapshots.
- name: Archive test snapshots if: always() uses: actions/upload-artifact@v3 with: name: test-snapshots path: | tests/testthat/_snaps/**/**/*
Step 2: Detect the environment to create variants
We can create a make_variant function to detect the version of the platform, as well as if we are running on CI.
This way even if we use the same OS on CI and locally, we can still differentiate between snapshots generated on CI and locally.
#' tests/testthat/setup.R is_ci <- function() { isTRUE(as.logical(Sys.getenv("CI"))) } make_variant <- function(platform = shinytest2::platform_variant()) { ci <- if (is_ci()) "ci" else NULL paste(c(ci, platform), collapse = "-") } # In tests: testthat::expect_snapshot(..., variant = make_variant())
Step 3: Ignore your local snapshots
Don’t check in snapshots generated on your machine. Add them to .gitignore instead.
Copy
tests/testthat/_snaps/linux-4.4
This way we can still generate snapshots locally to get fast feedback, but we’ll only keep a single source of truth checked in the repository.
Since you don’t track changes in local snapshots, you need to regenerate them before you start making changes to see if they change. It adds some complexity to the process, but it allows to keep the number of shared snapshots in the version control minimal.
Alternatively, you can keep local snapshots, but when doing code review, focus only on the ones generated on CI.
Step 4: Automate downloading snapshots from CI
To update snapshots generated on CI in Github, we need to:
Go to Actions.
Find our workflow run.
Download the test-snapshots artifact.
Unpack and overwrite the local snapshots.
testthat::snapshot_review() to review the changes.
Commit and push the changes.
This is a lot of steps. We can automate the most laborious ones with Github API.
The .download_ci_snaps function will:
Get the list of artifacts in the repository identified by repo and owner. It’ll search workflows generated from the branch we’re currently on. It will download the latest artifact with the provided name (in our case its “test-snapshots”) in the repository
Unzip them and overwrite the local copy of snapshots.
reactable: Column group definitions — colGroup
Use colGroup() to create column groups in a table.
Overview – Next Generation Shiny Apps with {bslib}
Welcome and Getting Started – Next Generation Shiny Apps with {bslib}
Welcome to the workshop and hello, bslib!
Prompt and empower your LLM, the tidy way
The tidyprompt package allows users to prompt and empower their large language models (LLMs) in a tidy way. It provides a framework to construct LLM prompts using tidyverse-inspired piping syntax, with a library of pre-built prompt wrappers and the option to build custom ones. Additionally, it supports structured LLM output extraction and validation, with automatic feedback and retries if necessary. Moreover, it enables specific LLM reasoning modes, autonomous R function calling for LLMs, and compatibility with any LLM provider.
How to enhance your R shiny application with httpOnly Cookies
httpOnly Cookies are crucial for security, protecting against cross-site scripting attacks in R Shiny apps. Read more about them here.
R Workflow
This work is intended to foster best practices in reproducible data documentation and manipulation, statistical analysis, graphics, and reporting.
Home · rocker-org/rocker Wiki
R configurations for Docker. Contribute to rocker-org/rocker development by creating an account on GitHub.
Writing R in VSCode: A Fresh Start - Kun Ren's Blog Posts
dreamRs/shinypop: Collection of notifications, confirm dialogs and alerts for 'Shiny' applications
Collection of notifications, confirm dialogs and alerts for 'Shiny' applications - dreamRs/shinypop
Using Cookie Based Authentication with Shiny · calligross.de
Experiment, Fail, Learn, Repeat
How To Reinstall Built-in App removed with Remove-AppxProvisionedPackage ?
Making Shiny apps faster with caching - RStudio
Shiny's 1.6 has a new function, bindCache(), which makes it easy to dramatically speed up reactive expressions and output rendering functions.
feddelegrand7/shinysnip: 👽 👽 👽 VSCode Extension for Generating Shiny Code Snippets.
feddelegrand7/rintimg: View an image in full screen by clicking on it
View an image in full screen by clicking on it. Contribute to feddelegrand7/rintimg development by creating an account on GitHub.
feddelegrand7/mailtoR: 🐹🐹🐹 Creates a Friendly User Interface for Emails Sending in Shiny and RMarkdown
🐹🐹🐹 Creates a Friendly User Interface for Emails Sending in Shiny and RMarkdown - feddelegrand7/mailtoR
feddelegrand7/scrollrevealR: Animate shiny elements when they scroll into view 🍁 🍁 🍁
Animate shiny elements when they scroll into view 🍁 🍁 🍁 - feddelegrand7/scrollrevealR
feddelegrand7/pivta: Create an Interactive Pivot Table with Data Analysis Tools
Create an Interactive Pivot Table with Data Analysis Tools - feddelegrand7/pivta
feddelegrand7/algo: Implement the Algolia Places Address Search Auto Completion Menu on Shiny Text Inputs
Implement the Algolia Places Address Search Auto Completion Menu on Shiny Text Inputs - feddelegrand7/algo
ThinkR-open/shinysnippets: A series of shiny related RStudio Snippets
A series of shiny related RStudio Snippets . Contribute to ThinkR-open/shinysnippets development by creating an account on GitHub.
Basic Data Exploration App
nanxstats/awesome-shiny-extensions: 🐝 Awesome R packages that offer extended UI or server components for the R web framework Shiny
🐝 Awesome R packages that offer extended UI or server components for the R web framework Shiny - nanxstats/awesome-shiny-extensions
5 Signs It's Time To Refactor Your Shiny Dashboard - Appsilon | End to End Data Science Solutions
jbryer/DTedit: Editable DataTables for shiny apps
Editable DataTables for shiny apps. Contribute to jbryer/DTedit development by creating an account on GitHub.
tidyverse/dtplyr: Data table backend for dplyr
Data table backend for dplyr. Contribute to tidyverse/dtplyr development by creating an account on GitHub.
RinteRface
HTML Static Template