Set the order of items in a dropdown menu
Usage
set_dropdown(path = ".", order = NULL, write = FALSE, folder)
set_episodes(path = ".", order = NULL, write = FALSE)
set_learners(path = ".", order = NULL, write = FALSE)
set_instructors(path = ".", order = NULL, write = FALSE)
set_profiles(path = ".", order = NULL, write = FALSE)
Arguments
- path
path to the lesson. Defaults to the current directory.
- order
the files in the order presented (with extension)
- write
if
TRUE
, the schedule will overwrite the schedule in the current file.- folder
one of four folders that sandpaper recognises where the files listed in
order
are located: episodes, learners, instructors, profiles.
Examples
tmp <- tempfile()
create_lesson(tmp, "test lesson")
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> ℹ No schedule set, using Rmd files in episodes/ directory.
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> → To remove this message, define your schedule in config.yaml or use `set_episodes()` to generate it.
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> ────────────────────────────────────────────────────────────────────────
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> ℹ To save this configuration, use
#>
#> set_episodes(path = path, order = ep, write = TRUE)
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> ✔ First episode created in /tmp/RtmpsPBux1/file1a88399c28d2/episodes/introduction.Rmd
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> ℹ Workflows up-to-date!
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> ℹ Consent to use package cache provided
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> → Searching for and installing available dependencies
#> * Discovering package dependencies ... Done!
#> * Copying packages into the library ... Done!
#> → Recording changes in lockfile
#> The following package(s) will be updated in the lockfile:
#>
#> # RSPM ===============================
#> - R6 [* -> 2.5.1]
#> - base64enc [* -> 0.1-3]
#> - bslib [* -> 0.4.2]
#> - cachem [* -> 1.0.6]
#> - cli [* -> 3.6.0]
#> - digest [* -> 0.6.31]
#> - ellipsis [* -> 0.3.2]
#> - evaluate [* -> 0.20]
#> - fastmap [* -> 1.1.0]
#> - fs [* -> 1.6.0]
#> - glue [* -> 1.6.2]
#> - highr [* -> 0.10]
#> - htmltools [* -> 0.5.4]
#> - jquerylib [* -> 0.1.4]
#> - jsonlite [* -> 1.8.4]
#> - knitr [* -> 1.42]
#> - lifecycle [* -> 1.0.3]
#> - magrittr [* -> 2.0.3]
#> - memoise [* -> 2.0.1]
#> - mime [* -> 0.12]
#> - rappdirs [* -> 0.3.3]
#> - renv [* -> 0.16.0]
#> - rlang [* -> 1.0.6]
#> - rmarkdown [* -> 2.20]
#> - sass [* -> 0.4.5]
#> - stringi [* -> 1.7.12]
#> - stringr [* -> 1.5.0]
#> - tinytex [* -> 0.43]
#> - vctrs [* -> 0.5.2]
#> - xfun [* -> 0.36]
#> - yaml [* -> 2.3.7]
#>
#> The version of R recorded in the lockfile will be updated:
#> - R [*] -> [4.2.2]
#>
#> * Lockfile written to '/tmp/RtmpsPBux1/file1a88399c28d2/renv/profiles/lesson-requirements/renv.lock'.
#> ✔ Lesson successfully created in /tmp/RtmpsPBux1/file1a88399c28d2
#> → Creating Lesson in /tmp/RtmpsPBux1/file1a88399c28d2...
#> /tmp/RtmpsPBux1/file1a88399c28d2
# Change the title and License
set_config(c(title = "Absolutely Free Lesson", license = "CC0"),
path = tmp,
write = TRUE
)
#> ℹ Writing to /tmp/RtmpsPBux1/file1a88399c28d2/config.yaml
#> → title: 'test lesson' -> title: 'Absolutely Free Lesson'
#> → license: 'CC-BY 4.0' -> license: 'CC0'
create_episode("using-R", path = tmp)
print(sched <- get_episodes(tmp))
#> [1] "introduction.Rmd" "using-r.Rmd"
# reverse the schedule
set_episodes(tmp, order = rev(sched))
#> episodes:
#> - using-r.Rmd
#> - introduction.Rmd
#>
#> ────────────────────────────────────────────────────────────────────────
#> ℹ To save this configuration, use
#>
#> set_episodes(path = tmp, order = rev(sched), write = TRUE)
# write it
set_episodes(tmp, order = rev(sched), write = TRUE)
# see it
get_episodes(tmp)
#> [1] "using-r.Rmd" "introduction.Rmd"