-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
152 lines (106 loc) · 8.15 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
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%"
)
```
# reuseme
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/reuseme)](https://CRAN.R-project.org/package=reuseme)
[![R-CMD-check](https://github.com/olivroy/reuseme/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/olivroy/reuseme/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/olivroy/reuseme/graph/badge.svg)](https://app.codecov.io/gh/olivroy/reuseme)
<!-- badges: end -->
The goal of reuseme is to provide utility functions for project management across RStudio projects.
Sometimes, managing multiple projects can be challenging. reuseme also aims to simplify project management on Windows.
You may need to switch quickly to a project, add things or browse a certain file if you have some replications across projects.
Sometimes, it is hard to do that.
reuseme also aims to help me overcome things I don't like on Windows.
## Installation {.unnumbered}
You can install reuseme like so:
``` r
# Cran
install.package("reuseme")
# R-universe (dev)
install.packages('reuseme', repos = c('https://olivroy.r-universe.dev', 'https://cloud.r-project.org'))
# From GitHub (dev)
pak::pak("olivroy/reuseme")
```
## Getting started
reuseme is adapted for a standard workflow, recommended in (find resources)
- Anyone working in RStudio (recent version for hyperlink support)
- Work with RStudio projects
- Your RStudio projects are organized in a centralized location on your computer
- Your RStudio projects are Version controlled with git (optional, but recommended for avoiding surprises! No need to be hosted on repositories like GitLab or GitHub)
- You use machine and human-readable paths (i.e. no spaces, special characters) (Tip: don't hesitate to rename your files (`reuseme::rename_files2()`), your future self will thank you!
To take advantage of reuseme, it is highly recommended to set the following option in your `.Rprofile`
``` r
options(reuseme.reposdir = c("~/rrr", "any-other-directories-that-contain-rstudio-projects"))
```
This will enable functions like `proj_switch()`, `proj_list()`, `use_todo()` to be optimized.
## Example
Since the package is meant for interactive use, there may not be a lot of code.
It takes advantage of [cli hyperlinks](https://cli.r-lib.org/reference/links.html) to improve productivity.
```{r}
#| title: hello
library(reuseme)
## basic example code
```
Most of these functions are meant to be used in RStudio, and in RStudio Projects, as they have not been widely tested outside this context.
In interactive sessions, you can use the `screenshot()` function to access an image in the clipboard and save it as .png in a `figures/` or `images/`directory in your RStudio project.
reuseme helps you work across projects, with the `proj_switch()` function.
`proj_switch()` works a lot like `usethis::proj_activate()` with the advantage of only typing the project name, instead of the full path.
By default, reuseme looks at `options(reuseme.reposdir)`, that is a vector of paths where repositories are located.
Personally, I use `~/rrr` (for my own projects) and `~/rrr-forks` (for projects I contribute to).
When not supplying the `proj` argument, many functions will just offer you to choose, with a user interface built on [cli hyperlinks](https://cli.r-lib.org/reference/links.html).
### Extend usethis functionality
usethis is fantastic to manage workflow within a project, but is harder across projects.
If you want to work across projects with [usethis](usethis.r-lib.org), you need to provide the full path to a project.
With reuseme, just use the project name!
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Workflow | reuseme | usethis |
+================================================================================+==================================================================================+======================================================================================================================================+
| Switch to project "cool-project" | `proj_switch(proj = "cool-project")` | `proj_activate(path = "C:/users/long/path/to/cool-project")` |
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Write a TODO item in project "cooler-project", while working in "cool-project" | `reuseme::use_todo(todo = "I need to do this ASAP as possible", proj = "cooler-project")` | `usethis::write_union(path = "C:/Users/I/do/not/want/to/type/cooler-project/TODO.R", lines = "I need to do this ASAP as possible.")` |
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Open pkgdown site link and see vignettes | 1. \`browse_pkg("usethis") | 1. `browse_package("usethis")` |
| | 2. Click on the hyperlinks that correspond to your query | 2. Type the correct number that corresponds |
| | | 3. `browseVignettes("usethis")` |
| | | 4. Open it |
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
: usethis vs reuseme
## Proposing a data analysis workflow
<!--# Write about dplyr-plus functions! -->
<!--# Write about *_identity functions -->
<!--# Write about _named functions -->
# Outline speed
```{r}
#| echo: false
#| output: false
# For example purpose, show all to spot potential files.
withr::local_envvar("TESTTHAT" = "true")
withr::local_options("reuseme.recent_indicator" = "")
```
Due to the growing number of criteria, regex, `file_outline()` is slowing down a bit. I will address that.
```{r}
#| warning: false
#| message: false
bench::mark(
outline <- proj_outline()
)
```
<details>
<summary>Example outline</summary>
<p>
```{r}
outline
```
</p>
</details>