index.md (1851B)
1 --- 2 title: "Viewing R Vignettes" 3 date: 2024-02-16T10:40:11-08:00 4 draft: false 5 categories: 6 - Data Science 7 tags: 8 - R 9 --- 10 11 To view a list of vignettes associated with a package (for example, 12 `dplyr`), enter the following command in any R console: 13 14 ```r 15 vignette(package = "dplyr") 16 ``` 17 18 You can also use: 19 20 ```r 21 browseVignettes("dplyr") 22 ``` 23 24 To see a specific vignette, use: 25 26 ```r 27 vignette("dplyr", package = "dplyr") 28 ``` 29 30 You can omit the `package` option when a vignette is uniquely named, and 31 many packages (by convention) contain an introductory vignette that shares 32 the package’s name. (I.e., `vignette("package_name")` will often work like 33 you’d expect.) 34 35 ## So what’s a _vignette_? 36 37 Vignettes are long-form guides to packages[^lf] and are installed onto your 38 system along with the rest of the package’s code and documentation. I’ve 39 known this for a while---I even [wrote 40 one](https://git.eamoncaddigan.net/GenderGuesser/file/vignettes/GenderGuesser.Rmd.html) 41 for my first R package---but I never took the time to learn how to access 42 them locally; instead I’ve always just looked at the list of vignettes on [a 43 package’s CRAN 44 page](https://cran.r-project.org/web/packages/dplyr/index.html) (which is 45 what you need to do if the package isn’t installed already). 46 47 Now that I’ve taken a moment to figure out how to use R’s vignette 48 functions, this is already saving me time. But it’s also useful in other 49 circumstances, such as writing code without reliable internet[^local], when 50 the installed version of a package doesn’t match the latest version on CRAN, 51 or for using packages that haven’t been listed on CRAN. 52 53 [^lf]: [Wickham, H., & Bryan, J. (2023). _R packages (2e)_. O'Reilly Media, 54 Inc.](https://r-pkgs.org/vignettes.html) 55 56 [^local]: Check out [Local-First 57 Software](https://www.inkandswitch.com/local-first/)