Practice, test 💪
If you don’t practice, you won’t learn anything
webr
test
Test your code directly in the R4DEV blog, enabled thanks to the quarto-live extension: R running in your browser, no installation needed.
Run the code
The windows below run R inside your browser –nothing to install, thanks to WebAssembly and the quarto-live extension. Edit the code, press Run Code, break things, fix them.
Below you can find a familiar exercise from the Plots session:
Your turn
Complete the code to count how many diamonds there are for each cut, from most to least common. If you get stuck, check the hint –and only then the solution.
NoteHint
count() takes the variable you want to tally. arrange(desc(n)) sorts the tally from largest to smallest.
TipSolution
library(dplyr)
diamonds |>
count(cut) |>
arrange(desc(n))