| Title: | Create Flashcards of Terms and Definitions |
|---|---|
| Description: | Provides functions for creating flashcard decks of terms and definitions. This package creates HTML slides using 'revealjs' that can be viewed in the 'RStudio' viewer or a web browser. Users can create flashcards from either existing built-in decks or create their own from CSV files or vectors of function names. |
| Authors: | Jeffrey R. Stevens [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-2375-1360>) |
| Maintainer: | Jeffrey R. Stevens <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0.9000 |
| Built: | 2026-05-12 06:45:33 UTC |
| Source: | https://github.com/jeffreyrstevens/flashr |
To create a data frame of functions that can be used to create a flashcard
deck, use build_functions_df(). This function calls extract_functions()
to find the functions if the file argument is specified. Otherwise, users
can pass a character vector of function names to the fs argument. Either
way, a title must be passed to title to create the data frame.
Users can then either complete the description column of the data frame
with their own descriptions or set the desc argument to TRUE to use
descriptions from
flashr_decks.
build_functions_df(file = NULL, fs = NULL, title, desc = TRUE, omit = TRUE)build_functions_df(file = NULL, fs = NULL, title, desc = TRUE, omit = TRUE)
file |
Character string of file name for text that includes code blocks. Can be local file or URL. |
fs |
If not using a file, character vector of functions
[do not include |
title |
Character string of title for flashcard deck (required) |
desc |
Logical for whether to search for descriptions from flashr_decks (default is TRUE, which includes descriptions from flashr_decks). |
omit |
Logical for whether to omit terms that have no descriptions from flashr_decks (default is TRUE, which omits terms with no descriptions). |
Data frame suitable to include in flashcard().
Other functions for extracting code and functions:
extract_code(),
extract_functions()
build_functions_df(fs = c("apple", "apply", "+"), title = "Test")build_functions_df(fs = c("apple", "apply", "+"), title = "Test")
This function prints a list of flashcard decks to the console and let's the user choose one of the decks. By default, the function searches the flashr_decks repo. But other GitHub repos can be used.
To narrow the results, include text in the pattern argument (for example,
choose_deck(pattern = "r4ds")).
choose_deck( pattern = NULL, choice = NULL, repo = "JeffreyRStevens/flashr_decks" )choose_deck( pattern = NULL, choice = NULL, repo = "JeffreyRStevens/flashr_decks" )
pattern |
String pattern to search in list of decks. |
choice |
Integer value of choice from list of decks if you already know which deck you would like to use without listing again. |
repo |
GitHub username and repo for deck repository in the format of "username/repository". Default value is "JeffreyRStevens/flashr_decks". |
Outputs a list of available built-in flashcard decks to the console, where the user can choose one of the decks to generate flashcards.
This function requires internet connectivity as it checks GitHub repos for decks.
Other functions for finding decks:
list_decks()
## Not run: # Choose from all available decks in default repository choose_deck() # Choose from decks including text matching pattern choose_deck(pattern = "r4ds") # Choose from decks from specific repository choose_deck(repo = "JeffreyRStevens/flashr_decks") ## End(Not run)## Not run: # Choose from all available decks in default repository choose_deck() # Choose from decks including text matching pattern choose_deck(pattern = "r4ds") # Choose from decks from specific repository choose_deck(repo = "JeffreyRStevens/flashr_decks") ## End(Not run)
The create_deck() function generates a set of flashcards with randomly
ordered pairs of terms and descriptions from a vector of functions provided
by the user. The function outputs reveal.js presentation as an HTML file.
If running in RStudio, the flashcards are output to the viewer.
Otherwise, they are output to a web browser.
create_deck( x, title = NULL, termsfirst = TRUE, package = TRUE, theme = "moon", file = NULL, random = TRUE, fontsize = "default", fontcolor = NULL, linkcolor = NULL, use_browser = FALSE )create_deck( x, title = NULL, termsfirst = TRUE, package = TRUE, theme = "moon", file = NULL, random = TRUE, fontsize = "default", fontcolor = NULL, linkcolor = NULL, use_browser = FALSE )
x |
Name of pre-existing flashcard deck or path and name of CSV file containing terms and descriptions |
title |
Title provided for flashcard deck. Defaults to "Custom deck" if not provided. |
termsfirst |
Logical indicating whether to show terms first (TRUE) or descriptions first (FALSE) |
package |
Logical indicating whether to include package name in term |
theme |
Name of reveal.js theme to use for flashcards |
file |
Path and file name used to save flashcard deck locally (must save as HTML) |
random |
Logical indicating whether to randomize order of terms (TRUE) or use order from data frame |
fontsize |
Base font size for presentation. Acceptable values include "default" (500%), "large" (700%), and "small" (300%). Custom values can be set as percentages (e.g., "250%"). |
fontcolor |
Font color for non-link text. Can be R color name, HTML color name, or hex code. |
linkcolor |
Font color for link text. Can be R color name, HTML color name, or hex code. |
use_browser |
Logical indicating whether to show the presentation in the RStudio viewer when available (FALSE) or the system's default browser (TRUE) |
An HTML file of terms and descriptions rendered in the RStudio viewer or web browser.
Other functions for creating decks:
flashcard()
# Display terms then descriptions my_functions <- c("as_tibble()", "bind_rows()", "c()") create_deck(x = my_functions) # Customize the title create_deck(x = my_functions, title = "My deck") # Save the HTML version of the flashcard deck locally create_deck(x = my_functions, title = "My deck", file = "my_deck.html")# Display terms then descriptions my_functions <- c("as_tibble()", "bind_rows()", "c()") create_deck(x = my_functions) # Customize the title create_deck(x = my_functions, title = "My deck") # Save the HTML version of the flashcard deck locally create_deck(x = my_functions, title = "My deck", file = "my_deck.html")
This flashcard deck includes terms associated with data types and structures.
data_typesdata_types
A data frame with 4 columns.
reference term or function
description or definition of term
URL for function documentation
package including function/argument
title of deck
To extract code blocks, apply extract_code() to R Markdown or Quarto files
either locally or via a URL. This function returns a character vector where
each line of content from an R code block is an element of the vector. Code
block options are not returned—only the content of the block. Code blocks
from other languages/engines (e.g., Python) are not returned.
extract_code(file, empty = TRUE, comments = TRUE)extract_code(file, empty = TRUE, comments = TRUE)
file |
Character string of file name for text that includes code blocks. Can be local file or URL. |
empty |
Logical indicating whether to include empty lines ( |
comments |
Logical indicating whether to include comment lines starting
with |
Returns character vector of individual lines of code.
This function is adapted from one Yihui Xie posted at https://yihui.org/en/2023/01/func-call/.
Other functions for extracting code and functions:
build_functions_df(),
extract_functions()
extract_code("https://raw.githubusercontent.com/JeffreyRStevens/flashr/refs/heads/main/README.Rmd")extract_code("https://raw.githubusercontent.com/JeffreyRStevens/flashr/refs/heads/main/README.Rmd")
This function finds all of the R functions in a character vector of R code.
For R scripts, first use readLines() or readr::read_file() to import
the script into a character vector. For R Markdown or Quarto documents,
first use extract_code() to find all of the R code in code blocks. The
character vector can then be passed to extract_functions() to find all of
the functions. By default, all instances of functions are returned. To omit
duplicate functions, set duplicates = FALSE.
extract_functions(code, duplicates = TRUE)extract_functions(code, duplicates = TRUE)
code |
Object that contains R code. |
duplicates |
Logical indicating whether to include duplicates of functions or whether to remove duplicates (default is TRUE, which includes duplicates). |
Returns character vector of function names without parentheses (e.g., it returns "library" rather than "library()") included in R code.
This function is adapted from one Yihui Xie posted at https://yihui.org/en/2023/01/func-call/.
Other functions for extracting code and functions:
build_functions_df(),
extract_code()
extract_functions(extract_code( "https://raw.githubusercontent.com/JeffreyRStevens/flashr/refs/heads/main/README.Rmd" ))extract_functions(extract_code( "https://raw.githubusercontent.com/JeffreyRStevens/flashr/refs/heads/main/README.Rmd" ))
The flashcard() function generates a set of flashcards with randomly
ordered pairs of terms and descriptions from built-in flashcard decks.
The function outputs reveal.js presentation as an HTML file.
If running in RStudio, the flashcards are output to the viewer.
Otherwise, they are output to a web browser.
flashcard( x, termsfirst = TRUE, package = TRUE, theme = "moon", file = NULL, random = TRUE, fontsize = "default", fontcolor = NULL, linkcolor = NULL, use_browser = FALSE, omit_na = TRUE )flashcard( x, termsfirst = TRUE, package = TRUE, theme = "moon", file = NULL, random = TRUE, fontsize = "default", fontcolor = NULL, linkcolor = NULL, use_browser = FALSE, omit_na = TRUE )
x |
Name of pre-existing flashcard deck or path and name of CSV file containing terms and descriptions |
termsfirst |
Logical indicating whether to show terms first (TRUE) or descriptions first (FALSE) |
package |
Logical indicating whether to include package name in term |
theme |
Name of reveal.js theme to use for flashcards |
file |
Path and file name used to save flashcard deck locally (must save as HTML) |
random |
Logical indicating whether to randomize order of terms (TRUE) or use order from data frame |
fontsize |
Base font size for presentation. Acceptable values include "default" (500%), "large" (700%), and "small" (300%). Custom values can be set as percentages (e.g., "250%"). |
fontcolor |
Font color for non-link text. Can be R color name, HTML color name, or hex code. |
linkcolor |
Font color for link text. Can be R color name, HTML color name, or hex code. |
use_browser |
Logical indicating whether to show the presentation in the RStudio viewer when available (FALSE) or the system's default browser (TRUE) |
omit_na |
Logical indicating whether to omit terms that have no descriptions from the deck (default is TRUE, which omits terms with no descriptions) |
An HTML file of terms and descriptions rendered in the RStudio viewer or web browser.
This function requires internet connectivity to use existing decks. An internet connection is not required if you supply a CSV file. However, without an internect connection, themes other than black, white, and serif, may not render properly, as they require access to Google Fonts.
Other functions for creating decks:
create_deck()
# Display terms then descriptions flashcard("data_types") # Display descriptions then terms flashcard("data_types", termsfirst = FALSE) # Display terms without package information flashcard("data_types", package = FALSE)# Display terms then descriptions flashcard("data_types") # Display descriptions then terms flashcard("data_types", termsfirst = FALSE) # Display terms without package information flashcard("data_types", package = FALSE)
This function searches for flashcard decks stored in GitHub repositories. By default, the function searches the flashr_decks repo. But other GitHub repos can be used.
To narrow the results, include text in the pattern argument (for example,
list_decks(pattern = "r4ds")).
list_decks( pattern = NULL, repo = "JeffreyRStevens/flashr_decks", quiet = FALSE )list_decks( pattern = NULL, repo = "JeffreyRStevens/flashr_decks", quiet = FALSE )
pattern |
String pattern to search in list of decks. |
repo |
GitHub username and repo for deck repository in the format of "username/repository". Default value is "JeffreyRStevens/flashr_decks". |
quiet |
Logical to prevent list information from printing to console. |
You are welcome to fork the
flashr_decks repo and
modify or add your own decks. Or you can create your own repo from scratch.
Just make sure to place your decks in a directory called decks/ in your
root directory. Then set the repo argument to your username and repo (see
Examples).
Outputs a list of available built-in flashcard decks to the console.
Other functions for finding decks:
choose_deck()
# View all available decks list_decks() # View decks with text matching pattern list_decks(pattern = "r4ds") # View decks from specific repository list_decks(repo = "JeffreyRStevens/flashr_decks")# View all available decks list_decks() # View decks with text matching pattern list_decks(pattern = "r4ds") # View decks from specific repository list_decks(repo = "JeffreyRStevens/flashr_decks")
This flashcard deck includes terms associated with vectors.
vectorsvectors
A data frame with 4 columns.
reference term or function
description or definition of term
package including function/argument
title of deck