A Simpler Way to Find Your Files

Constructs paths to your project's files. Declare the relative path of a file within your project with 'i_am()'. Use the 'here()' function as a drop-in replacement for 'file.path()', it will always locate the files relative to your project root.


here

Lifecycle:stable rcc CRANstatus Codecov testcoverage

The goal of the here package is to enable easy file referencing in project-oriented workflows. In contrast to using setwd(), which is fragile and dependent on the way you organize your files, here uses the top-level directory 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 any time you call here():

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

You can build a path relative to the top-level directory in order to read 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 source file lives inside your project, like analysis projects with data and reports in different subdirectories. See the included demo project for an example.

Illustration by Allison Horst


Code of Conduct

Please note that the here project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("here")

1.0.2 by Kirill Müller, a year ago


https://here.r-lib.org/, https://github.com/r-lib/here


Report a bug at https://github.com/r-lib/here/issues


Browse source code at https://github.com/cran/here


Authors: Kirill Müller [aut, cre] (ORCID: , Jennifer Bryan [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports rprojroot

Suggests conflicted, covr, fs, knitr, palmerpenguins, plyr, readr, rlang, rmarkdown, testthat, uuid, withr


Imported by ARUtools, AgePopDenom, BeeBDC, CohortSymmetry, DepMod, EZRShiny, GISSB, RAINBOWR, REDCapCAST, RastaRocket, SeroTrackR, adepro, autotest, bdc, blastula, brandr, cache, configulaR, denguedatahub, diffEnrich, elaborator, envDocument, filecacher, flow, folders, froggeR, funspotr, fusen, gitignore, gooseR, gtakeout, kindisperse, longsurr, misc, organizr, phdcocktail, popstudy, precommit, pressfreedom.data, qpost, r4lineups, rAccess, rUM, regions, reticulate, retroharmonize, rfold, rjtools, rworkflows, shiny2docker, srr, tugboat, upstartr, validateIt, weed, wither.

Suggested by APCalign, AzureAppInsights, CausalMixGPD, CohortCharacteristics, CohortConstructor, DrugExposureDiagnostics, DrugUtilisation, EIEntropy, Guerry, IncidencePrevalence, LifeInsureR, MHQoL, MiscMetabar, OmopIndices, OmopSketch, OmopStudyBuilder, OmopViewer, PUMP, PatientProfiles, PhenotypeR, Rbearcat, ReviewR, RplotterPkg, SCDB, SHAPforxgboost, SeaSondeR, Spectran, ViralEntropR, acledR, admiral, admiralneuro, admiralonco, admiralophtha, admiralpeds, aggreCAT, baskwrap, bayesTLS, beezdemand, betaARMA, boxr, bscui, caretSDM, cbcTools, ciTools, clockify, cnd, cpsvote, cricketdata, delimtools, designit, did, diseasystore, dtrackr, eemR, emayili, energyr, flourishcharts, formods, fromhere, fxl, galaxias, gghdx, ggseg, ggseg.formats, ghclass, graphicalMCP, greatR, gtfsrouter, gutenbergr, h3sdm, heddlr, heplots, heritable, hkdatasets, hmde, icecdr, isotracer, ixplorer, jetty, justifier, k5, logitr, logolink, logrx, lterdatasampler, mailmerge, maraca, marginaleffects, metabolic, metasurvey, mitey, mlr3spatiotempcv, morphemepiece, multiDoE, naijR, naniar, nestedLogit, omopgenerics, outstandR, pharmr, phytoclass, plotor, projects, rapsimng.decide.cultivar, rapsimng.decide.nitrogen, rapsimng.decide.sowing, rbranding, risk.assessr, rnassqs, salesforcer, semFromKeys, serodynamics, sfclust, sitrep, smdi, socialmixr, spDBL, sportsfeatures, srppp, ssddata, stRoke, styler, tatooheene, tcplfit2, test.assessr, tfrmtbuilder, tfruns, tibble, tidychangepoint, tidyprompt, tidyxl, toxEval, tsgc, unpivotr, vcdExtra, vegawidget, vembedr, vigicaen, visOmopResults, vitals, whep, wompwomp, x3ptools, xpose, yum, zmisc.


See at CRAN