Miscellaneous tips and tricks learnt from conference
Use of AI
- Cool tools for educational use:
- recraft.ai to generate consistent vector graphics - great for package stickers
- scribe to easily create step-by-step tutorials
- descript to modify video and audio recordings from transcript
- Features besides editing the video through transcript include modifying voice, remove silence, filler words, create eye contact and more
- See more in talk Practical Tips for using Generative AI in Data Science Workflows
- See the chattr R package
- Parametrise AI prompts using APIs
- See more in talk Using Generative AI to Increase the Impact of Your Data Science Work about use of the
vertexai
Python library to access Gemini API.
- See more in talk Using Generative AI to Increase the Impact of Your Data Science Work about use of the
Prompt engineering
- Use single detailed prompts “built” layer by layer.
- Approach like designing a ggplot: Start with a plot, then layer aesthetics, geometries, facets, and limits.
- Refer to links to help it along if you already know something about the subject, you are asking about
- For data storytelling: Give context such as “You are a data scientist who does a great job of explaining various outputs from data analysis and modeling, including numbers, tables, and plots, to help a more general audience understand your results better. Other details of model and what an inputted plot shows. Stick to only the data and information provided in creating your response. Your response should be understandable by a non-technical audience, 100 word or fewer, and in English.
DuckDB
See the notes from keynote Data Wrangling [for Python or R] Like a Boss With DuckDB, most specifically the section about duckplyr.
Positron
Quarto
See also What’s new - Quarto.
Tips working in Quarto
- Use
quarto preview
in terminal to open a tab that will update live when making changes to files.- Configure which file changes should trigger a re-rendering by using fx.
preview: watch: - "*.qmd"
in the_quarto.yml
file.
- Configure which file changes should trigger a re-rendering by using fx.
- Use of callouts
- Create custom classes by doing
::: {.new_class} ... :::
and defining the class in the.scss
file like.new_class { ... }
- Create custom classes by doing
- Use Quarto listings to create overviews of the available files in a directory
- Use
params:
at in YAML at top or documents and then reference them usingparams$
- Use
embed
to include figures, code or anything else in code chunks from other quarto documents or Jupyter notebooks- Fx. if analyses are performed which are to be used inside both an article and a slide show, save the analyses in an
analyses/
folder and just embed them from there in your other documents. Means there is one source of truth
- Fx. if analyses are performed which are to be used inside both an article and a slide show, save the analyses in an
- Can ctrl+V images in visual mode
Formats
Use templates!
- Revealjs for presentations
- Website for personal note taking: Quarto wiki template to create a Quarto website to host research notes, articles, glossaries, etc.
- Website with a blog: Repo for Cynthia Huang’s personal website
format: manuscript
for research notes- Similar to website but can be tied up to journal templates
Publishing
- Use existing GitHub actions
- See fx. the build_book.yaml action in R for data science.
- See general quarto actions by quarto_dev
- Use
pre-render
andpost-render
specified underproject
in your_quarto.yml
file to run code prior to or after rendering the site- Can fx. use
post-render
to run an R script that usesrsync
to “move” the_site
folder to a server location for deployment
- Can fx. use
Customisation
- Use CSS and javascript for customisation
- Mozilla web docs for help with fx. CSS
- Use AI to help write CSS and javascript
- Use DevTools via right-click -> inspect to look at the HTML
- Make changes to see how it affects the website
- Can be used on resulting HTMLs from rendering of quarto to help see structure and aid in writing of CSS to style
- See how other people’s websites are structured
- Include
.scss
files intheme
- Use
layer boundaries (/*-- scss:defaults --*/, /*-- scss:rules --*/, /*-- scss:mixins --*/, /*-- scss:functions --*/, or /*-- scss:uses --*/)
- Use
/*-- scss:defaults --*/
to define variables that can be referenced in the rules - like fx. colors
- Use
- Use
Miscellaneous other quarto notes
_common.R
file in project that setsoptions(...)
,knitr::opts_chunk$set(...)
, theme_set and update_geom_defaults- Look into execution management with freeze(:auto)
- Use of javascript extensions lightbox (allows reader to click image to enlarge) and masonry (grid layout library for customisation of image placements)
GitHub actions
See notes about GitHub actions from workshop with notes on fx.
General package development
Tip
See workshop notes Practical tips for working on production projects for nice practical tips on how to manage time, collaborate, tips on ensuring consistent high quality code as well as tips for package development in production
- Input/data validation:
- See checkmate for input validation
- See pointblank for data validation
- Use
dev_sitrep
- Ressources:
Other
API usage
- Use httr2 for HTTP requests
- Look into plumber API package
- See this cheatsheet
Computational statistics
Think of computational statistics as way of having only one test contrary to theoretical statistic, where need to think about what is the “right” distribution or test
Misc ressources
- R contributor site to get information on how to contribute to the R project.
- R Consortium Working Groups
- ROpenSci