-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
113 lines (89 loc) · 3.49 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# forgot <img src="man/figures/logo.png" align="right" height="139" />
<!-- badges: start -->
<!-- badges: end -->
The goal of forgot is to help you search for that one function you need in that one package. This package is based on functions from [Rd2roxygen](https://github.com/yihui/Rd2roxygen). The `forgot()` function returns a tibble of section content in R documentation files from a specified package (that's already installed). You can search on this tibble and return an interactive HTML table if needed. There's also a RStudio Addin included that you can use to search package documentation in a small Shiny app. `forgot2()` is for more casual use and will return a simple version of the forgot tibble with just the first two columns by default.
This package provides an alternative to function search without using the help system (`?help()`) in the RStudio IDE. You should still use that though for learning purposes.
## Installation
You can install the development version of forgot like so:
``` r
# install.packages("devtools")
devtools::install_github("parmsam/forgot")
```
## Examples
This are examples which show you how to solve common problems:
Create a forgot tibble that has columns for doc sections in package functions
```{r example, eval = T, message = F}
library(forgot)
library(dplyr)
## basic example code
functions_in_pkg <- forgot("stringr")
functions_in_pkg %>%
select(function_name, title, desc) %>%
head()
```
Search for a keyword of interest in the forgot tibble
```{r}
forgot("stringr", keyword = "count")
```
Or search for a keyword of interest only on specific fields
```{r}
forgot("stringr", keyword = "count", selected = c("title", "desc"))
```
If you want to search across multiple packages, here's an example of how you can use purrr to help with that
```{r eval = FALSE}
library(purrr)
c("stringr", "dplyr") %>%
purrr::set_names() %>%
map(forgot, keyword = "count") %>%
list_rbind(names_to = "Package")
```
Lastly, here's how you can get a reactable HTML table that you can search on
```{r eval= F}
forgot("stringr", keyword = "count", selected = c("title", "desc"),
interactive = T)
```
### Cat a roxygen2 field of interest into your R console
Here's how you can cat (?`cat()` for more info) the parameter field, usage field, or example field. Try it out to see how it looks.
```{r eval = F}
forgot_params("dplyr", "count")
forgot_usg("dplyr", "count")
forgot_exmpls("dplyr", "count")
```
The write logical (see `forgot_exmpls()` documentation for example) argument will create a new RStudio document with the roxygen2 field content of interest that was cat.
### Shortcuts
You can also use some shortcut operators to get the same results as above.
```{r eval = F}
# shortcut for forgot2
"dplyr" %f2% "count"
## OR
dplyr %f2% "count"
# shortcut for forgot_usg
"dplyr" %fu% "count"
## OR
dplyr %fu% count
# shortcut for forgot_exmpls
"dplyr" %fe% "count"
## OR
dplyr %fe% count
# shortcut for forgot_params
"dplyr" %fp% "count"
## OR
dplyr %fp% count
```
## Credits
- Hex icon created using the [hexmake
app](https://connect.thinkr.fr/hexmake/) from
[ColinFay](https://github.com/ColinFay/hexmake).
- <a href="https://www.flaticon.com/free-icons/confusion" title="confusion icons">Confusion icons created by Freepik - Flaticon</a>