Movatterモバイル変換


[0]ホーム

URL:


here

Lifecycle: stablerccCRAN statusCodecov test coverage

The goal of the here package is to enable easy file referencing inproject-oriented workflows.In contrast to usingsetwd(), which is fragile anddependent on the way you organize your files, here uses the top-leveldirectory of a project to easily build paths to files.

Installation

Install the released version of here from CRAN:

install.packages("here")

Usage

The here package creates paths relative to the top-level directory.The package displays the top-level of the current project on load or anytime you callhere():

here::i_am("README.Rmd")#> here() starts at /Users/kirill/git/R/r-lib/herehere()#> [1] "/Users/kirill/git/R/r-lib/here"

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

here("inst","demo-project","data","penguins.csv")#> [1] "/Users/kirill/git/R/r-lib/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 sourcefile lives inside your project, like analysis projects with data andreports in different subdirectories. See the includeddemoproject for an example.

Illustration byAllisonHorst


Code of Conduct

Please note that the here project is released with aContributor Code ofConduct. By contributing to this project, you agree to abide by itsterms.


[8]ページ先頭

©2009-2025 Movatter.jp