commit 95462c713d7e668e7ea6f56e11ec81a4b025ba31
parent da4362b3520b3b0f7ab975e8859f260585f50bb5
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date: Fri, 16 Feb 2024 11:55:34 -0800
Add a post about R vignettes
Diffstat:
1 file changed, 57 insertions(+), 0 deletions(-)
diff --git a/content/posts/r-vignettes/index.md b/content/posts/r-vignettes/index.md
@@ -0,0 +1,57 @@
+---
+title: "Viewing R Vignettes"
+date: 2024-02-16T10:40:11-08:00
+draft: false
+categories:
+- Data Science
+tags:
+- R
+---
+
+To view a list of vignettes associated with a package (for example,
+`dplyr`), enter the following command in any R console:
+
+```r
+vignette(package = "dplyr")
+```
+
+You can also use:
+
+```r
+browseVignettes("dplyr")
+```
+
+To see a specific vignette, use:
+
+```r
+vignette("dplyr", package = "dplyr")
+```
+
+You can omit the `package` option when a vignette is uniquely named, and
+many packages (by convention) contain an introductory vignette that shares
+the package’s name. (I.e., `vignette("package_name")` will often work like
+you’d expect.)
+
+## So what’s a _vignette_?
+
+Vignettes are long-form guides to packages[^lf] and are installed onto your
+system along with the rest of the package’s code and documentation. I’ve
+known this for a while---I even [wrote
+one](https://git.eamoncaddigan.net/GenderGuesser/file/vignettes/GenderGuesser.Rmd.html)
+for my first R package---but I never took the time to learn how to access
+them locally; instead I’ve always just looked at the list of vignettes on [a
+package’s CRAN
+page](https://cran.r-project.org/web/packages/dplyr/index.html) (which is
+what you need to do if the package isn’t installed already).
+
+Now that I’ve taken a moment to figure out how to use R’s vignette
+functions, this is already saving me time. But it’s also useful in other
+circumstances, such as writing code without reliable internet[^local], when
+the installed version of a package doesn’t match the latest version on CRAN,
+or for using packages that haven’t been listed on CRAN.
+
+[^lf]: [Wickham, H., & Bryan, J. (2023). _R packages (2e)_. O'Reilly Media,
+ Inc.](https://r-pkgs.org/vignettes.html)
+
+[^local]: Check out [Local-First
+ Software](https://www.inkandswitch.com/local-first/)