Flashcards are a great way to learn information. The repetition of
exposure to technical terms and their descriptions/definitions helps
with remembering those relationships (Yüksel et al., 2020)1. Hermans (2021)2 suggests
using flashcards for learning programming languages, which inspired the
{flashr}
package. The aim of this package is to create a
simple way to use and generate new decks of flashcards for learning R
function or anything else you want to learn!
{flashr}
has a number of built-in
flashcard decks to help you learn R, and especially the tidyverse. The workhorse of the
package is the flashcard()
function, which uses reveal.js3 to
generate an HTML presentation displaying terms and descriptions. For
RStudio users, the flashcard presentation will appear in the Viewer
pane. Outside of RStudio, the function will open the presentation in
your default browser. In either case, you can advance slides with the
right arrow key or by clicking the right arrow in the presentation.
For example, to create a set of flashcards from the built-in
data_types
deck, simply run:
The presentation will start with the title of the deck, then give a
blank slide, then present the first term, followed by the description,
and a blank slide. The order of terms/descriptions is randomized when
the flashcard()
function is run, so just re-run it to generate a different order.
By default, terms are presented before descriptions. So when you see
a term, you should try to define/describe the term. But it is possible
to present descriptions first so you can guess the term by including the
termfirst = FALSE
argument.
Another feature of flashcard()
is that it can present the name of the package for each function. Often
this is useful to distinguish base R function from functions that
require other packages. By default, presentations include the package
names. However, you can turn this off with
package = FALSE
.
Because {flashr}
uses reveal.js to create the
presentations, it can use the available reveal.js themes. By default, flashcard()
uses the moon
theme, but if that doesn’t suit you, you can
change the theme by setting the theme
argument. At the
moment, available themes are black
, white
,
league
, beige
, sky
,
night
, serif
, simple
,
solarized
, blood
, and moon
.
Currently, {flashr}
includes a few example decks
(data_types
, vectors
) and decks of functions
and arguments derived from R for Data
Science (first edition). These decks are housed at the flashr_decks
GitHub repo, and more are on the way.
To see what decks are available, use list_decks()
:
list_decks()
#> Available flashcard decks
#> 1. Data types (data_types)
#> 2. Operators (operators)
#> 3. PsyTeachR ADS Ch. 1 (psyteachr_ads1)
#> 4. PsyTeachR ADS Ch. 2 (psyteachr_ads2)
#> 5. PsyTeachR ADS Ch. 3 (psyteachr_ads3)
#> 6. PsyTeachR ADS Ch. 4 (psyteachr_ads4)
#> 7. PsyTeachR ADS Ch. 5 (psyteachr_ads5)
#> 8. PsyTeachR ADS Ch. 7 (psyteachr_ads7)
#> 9. PsyTeachR ADS Ch. 8 (psyteachr_ads8)
#> 10. PsyTeachR ADS Ch. 9 (psyteachr_ads9)
#> 11. PsyTeachR DSRR Ch. 1 (psyteachr_dsrr1)
#> 12. PsyTeachR DSRR Ch. 2 (psyteachr_dsrr2)
#> 13. PsyTeachR DSRR Ch. 3 (psyteachr_dsrr3)
#> 14. PsyTeachR DSRR Ch. 4 (psyteachr_dsrr4)
#> 15. PsyTeachR DSRR Ch. 5 (psyteachr_dsrr5)
#> 16. PsyTeachR DSRR Ch. 6 (psyteachr_dsrr6)
#> 17. PsyTeachR DSRR Ch. 7 (psyteachr_dsrr7)
#> 18. PsyTeachR DSRR Ch. 8 (psyteachr_dsrr8)
#> 19. PsyTeachR DSRR Ch. 9 (psyteachr_dsrr9)
#> 20. PsyTeachR DSRR Ch. 10 (psyteachr_dsrr10)
#> 21. PsyTeachR QFA Ch. 1 (psyteachr_qfa1)
#> 22. PsyTeachR QFA Ch. 2 (psyteachr_qfa2)
#> 23. PsyTeachR QFA Ch. 3 (psyteachr_qfa3)
#> 24. PsyTeachR QFA Ch. 4 (psyteachr_qfa4)
#> 25. PsyTeachR QFA Ch. 5 (psyteachr_qfa5)
#> 26. PsyTeachR QFA Ch. 6 (psyteachr_qfa6)
#> 27. PsyTeachR QFA Ch. 7 (psyteachr_qfa7)
#> 28. PsyTeachR QFA Ch. 8 (psyteachr_qfa8)
#> 29. PsyTeachR QFA Ch. 9 (psyteachr_qfa9)
#> 30. PsyTeachR QFA Ch. 10 (psyteachr_qfa10)
#> 31. PsyTeachR QFA Ch. 11 (psyteachr_qfa11)
#> 32. R4DS Ch. 1 (r4ds1)
#> 33. R4DS Ch. 3 (r4ds3)
#> 34. R4DS Ch. 5 (r4ds5)
#> 35. R4DS Ch. 7 (r4ds7)
#> 36. R4DS Ch. 8 (r4ds8)
#> 37. R4DS Ch. 10 (r4ds10)
#> 38. R4DS Ch. 11 (r4ds11)
#> 39. R4DS Ch. 12 (r4ds12)
#> 40. R4DS Ch. 13 (r4ds13)
#> 41. R4DS Ch. 14 (r4ds14)
#> 42. R4DS Ch. 15 (r4ds15)
#> 43. R4DS Ch. 16 (r4ds16)
#> 44. R4DS Ch. 18 (r4ds18)
#> 45. R4DS Ch. 19 (r4ds19)
#> 46. R4DS Ch. 20 (r4ds20)
#> 47. R4DS Ch. 21 (r4ds21)
#> 48. R4DS Ch. 23 (r4ds23)
#> 49. R4DS Ch. 25 (r4ds25)
#> 50. R4DS Ch. 27 (r4ds27)
#> 51. R4DS Ch. 28 (r4ds28)
#> 52. R4DS Ch. 29 (r4ds29)
#> 53. R4DS Ch. 30 (r4ds30)
#> 54. Vectors (vectors)
Note that the list of decks includes the deck names in parenthesis
next to the descriptions. For instance, for R4DS Chapter 3, the
name is r4ds3
.
This function includes pattern matching. So if you want to narrow you list down, add a search string.
list_decks(pattern = "r4ds")
#> Available flashcard decks
#> 1. R4DS Ch. 1 (r4ds1)
#> 2. R4DS Ch. 3 (r4ds3)
#> 3. R4DS Ch. 5 (r4ds5)
#> 4. R4DS Ch. 7 (r4ds7)
#> 5. R4DS Ch. 8 (r4ds8)
#> 6. R4DS Ch. 10 (r4ds10)
#> 7. R4DS Ch. 11 (r4ds11)
#> 8. R4DS Ch. 12 (r4ds12)
#> 9. R4DS Ch. 13 (r4ds13)
#> 10. R4DS Ch. 14 (r4ds14)
#> 11. R4DS Ch. 15 (r4ds15)
#> 12. R4DS Ch. 16 (r4ds16)
#> 13. R4DS Ch. 18 (r4ds18)
#> 14. R4DS Ch. 19 (r4ds19)
#> 15. R4DS Ch. 20 (r4ds20)
#> 16. R4DS Ch. 21 (r4ds21)
#> 17. R4DS Ch. 23 (r4ds23)
#> 18. R4DS Ch. 25 (r4ds25)
#> 19. R4DS Ch. 27 (r4ds27)
#> 20. R4DS Ch. 28 (r4ds28)
#> 21. R4DS Ch. 29 (r4ds29)
#> 22. R4DS Ch. 30 (r4ds30)
If you want to list the decks and then choose one, use choose_deck()
:
#> Available flashcard decks
#> 1. R4DS Ch. 1 (r4ds1)
#> 2. R4DS Ch. 3 (r4ds3)
#> 3. R4DS Ch. 5 (r4ds5)
#> 4. R4DS Ch. 7 (r4ds7)
#> 5. R4DS Ch. 8 (r4ds8)
#> 6. R4DS Ch. 10 (r4ds10)
#> 7. R4DS Ch. 11 (r4ds11)
#> 8. R4DS Ch. 12 (r4ds12)
#> 9. R4DS Ch. 13 (r4ds13)
#> 10. R4DS Ch. 14 (r4ds14)
#> 11. R4DS Ch. 15 (r4ds15)
#> 12. R4DS Ch. 16 (r4ds16)
#> 13. R4DS Ch. 18 (r4ds18)
#> 14. R4DS Ch. 19 (r4ds19)
#> 15. R4DS Ch. 20 (r4ds20)
#> 16. R4DS Ch. 21 (r4ds21)
#> 17. R4DS Ch. 23 (r4ds23)
#> 18. R4DS Ch. 25 (r4ds25)
#> 19. R4DS Ch. 27 (r4ds27)
#> 20. R4DS Ch. 28 (r4ds28)
#> 21. R4DS Ch. 29 (r4ds29)
#> 22. R4DS Ch. 30 (r4ds30)
#> Please enter the number for a deck or 0 to exit:
Or, if you already know the deck number that you want, you can
include it in the choice
argument.
Of course, a faster way to do this is to enter the deck name directly
into flashcard()
.
You can also view examples of all of the decks in HTML.
In addition to built-in decks, you can create your own decks by either making a CSV file with the terms and descriptions or passing a vector of functions from the flashr_decks list of functions.
Simply create a CSV file that includes a column labeled
term
and a column labeled description
. You can
also include a package
column listing package names and a
title
column to give your presentation a title, but these
are optional arguments4. Here is an example of a CSV file with all
of the columns.
term | description | package | title |
---|---|---|---|
= | assignment operator | base | Operators |
<- | assignment operator | base | |
|> | pipe operator (base R) | base | |
+ | addition | base | |
- | subtraction | base | |
* | multiplication | base | |
/ | division | base | |
%% | modulo or remainder | base | |
%/% | integer division or quotient | base | |
^ | exponent | base | |
> | greater than | base | |
< | less than | base | |
<= | greater than or equal to | base | |
>= | less than or equal to | base | |
== | equal to | base | |
!= | not equal to | base | |
& | logical AND | base | |
| | logical OR | base | |
! | logical NOT | base | |
: | sequence of integers | base | |
%in% | identify if element is in vector | base | |
%*% | multiply matrix with its transpose | base | |
:: | export variable from package for use | base |
You can, of course, store those decks on your local computer to use them. But if your decks may be useful for other people (for example, based on books or publicly available resources), consider submitting them to the flashr_decks repo.
Alternatively, you can create your own repo of decks and specify with
the repo
argument. Just make sure that your CSV files are
saved in a decks/
folder in your repo’s root directory.
list_decks(repo = "JeffreyRStevens/flashr_decks")
#> Available flashcard decks
#> 1. Data types (data_types)
#> 2. Operators (operators)
#> 3. PsyTeachR ADS Ch. 1 (psyteachr_ads1)
#> 4. PsyTeachR ADS Ch. 2 (psyteachr_ads2)
#> 5. PsyTeachR ADS Ch. 3 (psyteachr_ads3)
#> 6. PsyTeachR ADS Ch. 4 (psyteachr_ads4)
#> 7. PsyTeachR ADS Ch. 5 (psyteachr_ads5)
#> 8. PsyTeachR ADS Ch. 7 (psyteachr_ads7)
#> 9. PsyTeachR ADS Ch. 8 (psyteachr_ads8)
#> 10. PsyTeachR ADS Ch. 9 (psyteachr_ads9)
#> 11. PsyTeachR DSRR Ch. 1 (psyteachr_dsrr1)
#> 12. PsyTeachR DSRR Ch. 2 (psyteachr_dsrr2)
#> 13. PsyTeachR DSRR Ch. 3 (psyteachr_dsrr3)
#> 14. PsyTeachR DSRR Ch. 4 (psyteachr_dsrr4)
#> 15. PsyTeachR DSRR Ch. 5 (psyteachr_dsrr5)
#> 16. PsyTeachR DSRR Ch. 6 (psyteachr_dsrr6)
#> 17. PsyTeachR DSRR Ch. 7 (psyteachr_dsrr7)
#> 18. PsyTeachR DSRR Ch. 8 (psyteachr_dsrr8)
#> 19. PsyTeachR DSRR Ch. 9 (psyteachr_dsrr9)
#> 20. PsyTeachR DSRR Ch. 10 (psyteachr_dsrr10)
#> 21. PsyTeachR QFA Ch. 1 (psyteachr_qfa1)
#> 22. PsyTeachR QFA Ch. 2 (psyteachr_qfa2)
#> 23. PsyTeachR QFA Ch. 3 (psyteachr_qfa3)
#> 24. PsyTeachR QFA Ch. 4 (psyteachr_qfa4)
#> 25. PsyTeachR QFA Ch. 5 (psyteachr_qfa5)
#> 26. PsyTeachR QFA Ch. 6 (psyteachr_qfa6)
#> 27. PsyTeachR QFA Ch. 7 (psyteachr_qfa7)
#> 28. PsyTeachR QFA Ch. 8 (psyteachr_qfa8)
#> 29. PsyTeachR QFA Ch. 9 (psyteachr_qfa9)
#> 30. PsyTeachR QFA Ch. 10 (psyteachr_qfa10)
#> 31. PsyTeachR QFA Ch. 11 (psyteachr_qfa11)
#> 32. R4DS Ch. 1 (r4ds1)
#> 33. R4DS Ch. 3 (r4ds3)
#> 34. R4DS Ch. 5 (r4ds5)
#> 35. R4DS Ch. 7 (r4ds7)
#> 36. R4DS Ch. 8 (r4ds8)
#> 37. R4DS Ch. 10 (r4ds10)
#> 38. R4DS Ch. 11 (r4ds11)
#> 39. R4DS Ch. 12 (r4ds12)
#> 40. R4DS Ch. 13 (r4ds13)
#> 41. R4DS Ch. 14 (r4ds14)
#> 42. R4DS Ch. 15 (r4ds15)
#> 43. R4DS Ch. 16 (r4ds16)
#> 44. R4DS Ch. 18 (r4ds18)
#> 45. R4DS Ch. 19 (r4ds19)
#> 46. R4DS Ch. 20 (r4ds20)
#> 47. R4DS Ch. 21 (r4ds21)
#> 48. R4DS Ch. 23 (r4ds23)
#> 49. R4DS Ch. 25 (r4ds25)
#> 50. R4DS Ch. 27 (r4ds27)
#> 51. R4DS Ch. 28 (r4ds28)
#> 52. R4DS Ch. 29 (r4ds29)
#> 53. R4DS Ch. 30 (r4ds30)
#> 54. Vectors (vectors)
We’ve collected all of the functions in the currently available decks
in a table
at the flashr_decks repo. The create_deck()
function takes a vector that you create of functions from the function
list. Make sure to include the ()
at the end of the
function name (except for operators)! And don’t forget to include a
title.
my_functions <- c("%>%", "ggplot()", "aes()", "geom_point()")
create_deck(my_functions,
title = "ggplot basics"
)
All of the arguments from flashcard()
apply to create_deck()
,
so you can customize the theme, fonts, etc. and save the output
locally.
These flashcards were designed to learn programming
functions/arguments and their definitions. But {flashr}
can
be use for any pairing of terms and descriptions, computing-based or
otherwise. So feel free to make flashcard decks of whatever you want to
learn: words from a language that you are learning, terms you’re
studying for classes, whatever you need!
Yüksel, H. G., Mercanoğlu, H. G., & Yılmaz, M. B. (2020). Digital flashcards vs. Wordlists for learning technical vocabulary. Computer Assisted Language Learning, 0(0), 1–17. https://doi.org/10.1080/09588221.2020.1854312↩︎
Hermans, F. (2021). The Programmer’s Brain. Manning. https://www.manning.com/books/the-programmers-brain↩︎
Note title
is required when submitting to
flashr_decks↩︎