Skip to content

Commit

Permalink
Merge pull request #63 from r-lib/f-lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Nov 15, 2020
2 parents 07bd36d + 3d007f9 commit 859ad27
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion R/aaa.R
Expand Up @@ -2,7 +2,7 @@
format_root_section <- function() {
paste(
"\\section{Project root}{",
"The project root is established with a call to [here::i_am()].",
"The project root is established with a call to `here::`[here::i_am()].",
"Although not recommended, it can be changed by calling `here::i_am()` again.",
"",
"In the absence of such a call (e.g. for a new project),",
Expand Down
2 changes: 2 additions & 0 deletions R/dr_here.R
Expand Up @@ -6,6 +6,8 @@
#' @param show_reason `[logical(1)]`\cr
#' Include reason in output of `dr_here()`, defaults to `TRUE`.
#' @export
#' @examples
#' dr_here()
dr_here <- function(show_reason = TRUE) {
message(format_dr_here(show_reason = show_reason))
}
Expand Down
14 changes: 6 additions & 8 deletions README.Rmd
Expand Up @@ -4,7 +4,7 @@ output: downlit::readme_document

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, echo = FALSE}
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
Expand Down Expand Up @@ -39,21 +39,19 @@ install.packages("here")
The here package creates paths relative to the top-level directory. The package displays the top-level of the current project on load or any time you call `here()`:

```{r}
library(here)
here::i_am("README.Rmd")
here()
```

You can build a path relative to the top-level directory in order to read or write a file:

```{r, eval = FALSE}
here("files", "data", "penguins.csv")
```

```{r, eval = FALSE}
write.csv(palmerpenguins::penguins, here("files", "data", "penguins.csv"))
```{r}
here("inst", "demo-project", "data", "penguins.csv")
readr::write_csv(palmerpenguins::penguins, here("inst", "demo-project", "data", "penguins.csv"))
```

These relative paths work regardless of where the associated source file lives inside your project, like analysis projects with data and reports in different subdirectories.
See the included [demo project](https://github.com/r-lib/here/tree/master/inst/demo-project) for an example.

![](https://raw.githubusercontent.com/allisonhorst/stats-illustrations/master/rstats-artwork/here.png)
*Illustration by [Allison Horst](https://github.com/allisonhorst)*
Expand Down
18 changes: 7 additions & 11 deletions README.md
@@ -1,10 +1,5 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->

<pre class='chroma'>
<span class='c'>## Loading here</span>

<span class='c'>## here() starts at /home/kirill/git/R/here</span></pre>

# here

<!-- badges: start -->
Expand All @@ -27,18 +22,19 @@ Install the released version of here from CRAN:
The here package creates paths relative to the top-level directory. The package displays the top-level of the current project on load or any time you call `here()`:

<pre class='chroma'>
<span class='kr'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='o'>(</span><span class='nv'><a href='https://here.r-lib.org/'>here</a></span><span class='o'>)</span>
<span class='nf'><a href='https://here.r-lib.org//reference/here.html'>here</a></span><span class='o'>(</span><span class='o'>)</span>
<span class='nf'>here</span><span class='nf'>::</span><span class='nf'><a href='https://here.r-lib.org//reference/i_am.html'>i_am</a></span><span class='o'>(</span><span class='s'>"README.Rmd"</span><span class='o'>)</span>
<span class='c'>#&gt; here() starts at /home/kirill/git/R/here</span>
<span class='nf'>here</span><span class='o'>(</span><span class='o'>)</span>
<span class='c'>#&gt; [1] "/home/kirill/git/R/here"</span></pre>

You can build a path relative to the top-level directory in order to read or write a file:

<pre class='chroma'>
<span class='nf'><a href='https://here.r-lib.org//reference/here.html'>here</a></span><span class='o'>(</span><span class='s'>"files"</span>, <span class='s'>"data"</span>, <span class='s'>"penguins.csv"</span><span class='o'>)</span></pre>
<pre class='chroma'>
<span class='nf'><a href='https://rdrr.io/r/utils/write.table.html'>write.csv</a></span><span class='o'>(</span><span class='nf'>palmerpenguins</span><span class='nf'>::</span><span class='nv'><a href='https://allisonhorst.github.io/palmerpenguins/reference/penguins.html'>penguins</a></span>, <span class='nf'><a href='https://here.r-lib.org//reference/here.html'>here</a></span><span class='o'>(</span><span class='s'>"files"</span>, <span class='s'>"data"</span>, <span class='s'>"penguins.csv"</span><span class='o'>)</span><span class='o'>)</span></pre>
<span class='nf'>here</span><span class='o'>(</span><span class='s'>"inst"</span>, <span class='s'>"demo-project"</span>, <span class='s'>"data"</span>, <span class='s'>"penguins.csv"</span><span class='o'>)</span>
<span class='c'>#&gt; [1] "/home/kirill/git/R/here/inst/demo-project/data/penguins.csv"</span>
<span class='nf'>readr</span><span class='nf'>::</span><span class='nf'><a href='https://readr.tidyverse.org/reference/write_delim.html'>write_csv</a></span><span class='o'>(</span><span class='nf'>palmerpenguins</span><span class='nf'>::</span><span class='nv'><a href='https://allisonhorst.github.io/palmerpenguins/reference/penguins.html'>penguins</a></span>, <span class='nf'>here</span><span class='o'>(</span><span class='s'>"inst"</span>, <span class='s'>"demo-project"</span>, <span class='s'>"data"</span>, <span class='s'>"penguins.csv"</span><span class='o'>)</span><span class='o'>)</span></pre>

These relative paths work regardless of where the associated source file lives inside your project, like analysis projects with data and reports in different subdirectories.
These relative paths work regardless of where the associated source file lives inside your project, like analysis projects with data and reports in different subdirectories. See the included [demo project](https://github.com/r-lib/here/tree/master/inst/demo-project) for an example.

![](https://raw.githubusercontent.com/allisonhorst/stats-illustrations/master/rstats-artwork/here.png) *Illustration by [Allison Horst](https://github.com/allisonhorst)*

Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Expand Up @@ -30,7 +30,7 @@
- [x] Ensure that dependency between source files is cycle-free, as in https://github.com/yonicd/foreman/issues/2
- [x] Ensure that source files correspond to test files via `devtools::test_coverage_file()`
- [x] Import rlang where appropriate
- [ ] Close open issues
- [x] Close open issues
- [x] Deprecate functions that have moved somewhere else
- [x] Avoid `iris`
- [x] Synchronize with own downstream packages
Expand Down
3 changes: 3 additions & 0 deletions man/dr_here.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/figures/lifecycle-archived.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-defunct.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-deprecated.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-experimental.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-maturing.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-questioning.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-soft-deprecated.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-stable.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-superseded.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/here.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 859ad27

Please sign in to comment.