rstudio-conf-2022 / build-tidy-tools Goto Github PK
View Code? Open in Web Editor NEWBuilding tidy tools workshop
Home Page: https://rstd.io/btt
License: Creative Commons Attribution Share Alike 4.0 International
Building tidy tools workshop
Home Page: https://rstd.io/btt
License: Creative Commons Attribution Share Alike 4.0 International
One of the things initially discussed with @3mmaRand was that we would divide the course roughly as:
Instructor | Day | Theme |
---|---|---|
Emma | 1 | packages |
Ian | 2 | functions |
We could aim things so that the class would start the second day with a package that contains some small number of pure functions.
Assuming this, and seeing that each day has four sessions, here's a first pass for what I have in mind:
...
, details)rlang::abort()
dplyr::group_by()
as_function()
, vctrs, and miscellanyrlang::as_function()
format()
method gets you a long wayOnce this issue is settled, I'll open an issue to discuss each session in greater detail.
What do folks think?
following Slack suggestions
Build documentation
🎬 Run devtools::document()
MISSING COMMAND
ℹ Updating ussie documentation
ℹ Loading ussie
Writing NAMESPACE
Writing uss_make_matches.Rd
Warning message:
[matches.R:13] @examples requires a value
1100 - 1230
Learning Objectives
At the end of this section you will be able to:
to..
be..
added
Why? and definitions
exploring in console gets tedious
write unit tests instead - automates testing
improve interface, readability
what is a unit?
what is coverage
Workflow
use package started in Session 1
use function created in Session 1
use_test()
what happens? creates tests/testthat/ and test-xxxx.R where xxxx is the same name as the file with the function.
one test file per .R in R/
Most impt: expect_equal(obj, exp). Other: expect_true(), expect_type() and expect_length()
Set up keyborad shortcuts for testing workflow??
Report test coverage for a file Cmd+R `test_coverage_active_file()
Report test coverage for a package Shift+Cmd+R devtools::test_coverage()
Run a test file Cmd-T devtools::test_file()
Test driven development
Day 1
By the end of the session, you will be able to:
Some principles to keep in mind:
move: usethis::use_import_from("tibble", "tibble")
to Pkg Dependencies
day 1 went very well! I noted a few typos, so I'll put them all in a big PR
By the end of the session, you will be able to:
1100 - 1230
At the end of this section you will be able to:
use_test()
.R
in R/
expect_equal(obj, exp)
. Other: expect_true()
, expect_type()
and expect_length()
devtools::test_coverage()
devtools::test_file()
1530 -1700
At the end of this section you will be able to:
Big picture goes in the README: usethis::use_readme_rmd()
usethis::use_news_md()
see the tidyverse style guideusethis::use_vignette("name of vignette")
vignettes/
folderusethis::use_pkgdown()
devtools::build_site()
usethis::use_github_action("pkgdown")
This finally clicked for me when I rewatched Lionel Henry's rstudio::conf presentation: https://www.youtube.com/watch?v=SW_TUkPXSmA
The purpose of all_of()
and any_of()
is to disambiguate data-variables from environment-variables in tidy select:
library("dplyr")
cyl <- c("mpg", "wt")
mtcars |> select(cyl)
mtcars |> select(all_of(cyl))
We need to use it only when we are making a tidy-select specification using a variable and we want to ensure that the variable is not interpreted in the context of the data frame.
this is needed for the scale to work in uss_plot_seasons_tiers()
I'll make a quick PR here; this will give @3mmaRand a chance to weigh in if this will be the right spot to make the change.
Add a section on what to do if set up is a problem: we can use RStudio cloud, will need particpants to make an account and get an instructor account from Mine
Chesapeake F
switch dev workflow to mermaid
At the end of this section you will be able to:
ref: The Grand Unified Theory of Documentation https://documentation.divio.com/
the DESCRIPTION file
view others e.g., ggplot2
Set up your .Rprofile usethis::edit_r_profile
devtools::check()
usethis::use_package()
devtools::check()
again..R
files #'
and @
@param arg
---- describe the inputs@examples
---- show how the function works@seealso
---- point out related functions@returns
---- describe the outputs@param arg
---- is this a user visible functiondevtools::document()
wrapper for roxygen2 functionexchange the word 'test' for 'experiment with' or similar to avoid confusion with unit testing
By the end of this session, you will be able to:
dplyr::group_by()
given our shortlink 🎉, I'd like to make the materials as "close" as possible to the target of the link
1330 -1500 and 1530 -1700 (haven't decided where to split materials yet)
At the end of this section you will be able to:
ref: The Grand Unified Theory of Documentation https://documentation.divio.com/
recall the error from devtools::check()
components
usethis
helpers
view DESCRIPTION
Set up your .Rprofile usethis::edit_r_profile
devtools::check()
usethis::use_package()
devtools::check()
again..R
files #'
and @
@param arg
---- describe the inputs@examples
---- show how the function works@seealso
---- point out related functions@returns
---- describe the outputs@param arg
---- is this a user visible functiondevtools::document()
wrapper for roxygen2 function⬆️ session 3 ?
⬇️ session 4 ?
Big picture goes in the README: usethis::use_readme_rmd()
usethis::use_news_md()
see the tidyverse style guideusethis::use_vignette("name of vignette")
vignettes/
folderusethis::use_pkgdown()
devtools::build_site()
usethis::use_github_action("pkgdown")
Day 1
I rarely make bitly links, but I noticed that it seems like you need a paid account to generate custom links (I don't have one).
If we were to use a custom link, I was thinking:
btt22 - taken
btt-22 - still there
If need be, could RStudio generate a link?
By the end of this session, you will be able to:
format()
method gets you a long wayha!
0900 - 1030
At the end of this section you will be able to:
load_all()
check()
Version, R.home(), .Library .libPaths()
From: CRAN, GitHub, Bioconductor
Script | Pacakge |
---|---|
one-off data analysis | defines reusable components |
defined by .R extension | defined by presence of DESCRIPTION file |
library() calls |
Required packages specified in DESCRIPTION, made available in NAMESPACE file |
documentation in # comments | documentation in files and Roxygen comments |
source() |
Install and restart |
use our demo pkg??
Making a minimal version controlled package linked to a remote repository on GitHub using the devtools approach.
usethis::create_package
R/
, NAMESPACE, .Rbuildignore .gitignoreusethis::use_r()
devtools::load_all()
devtools::check()
devtools::install()
devtools::document()
, (maybe leave until session 3)?function
things that fit into RStudio pane do not fit into fullscreen
license is loading as home page presumably because license in the project directory with the _quarto.yml
Can we specify we is home page?
or
Can the build directory for the website be matierls rather than the project dir?
my plan is to get a set of slides done, then to add in the references
my goodness, I'm glad I had the chance to stumble on tidy eval in "practice"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.