{"id":13858387,"url":"https://github.com/r-lib/rprojroot","last_synced_at":"2025-12-12T01:05:39.430Z","repository":{"id":32279007,"uuid":"35853742","full_name":"r-lib/rprojroot","owner":"r-lib","description":"Finding files in project subdirectories","archived":false,"fork":false,"pushed_at":"2025-02-10T19:29:39.000Z","size":1233,"stargazers_count":149,"open_issues_count":2,"forks_count":24,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-06T21:02:25.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rprojroot.r-lib.org/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-19T02:10:40.000Z","updated_at":"2025-03-22T11:12:45.000Z","dependencies_parsed_at":"2024-01-13T07:02:36.972Z","dependency_job_id":"dd991f61-874a-4d99-ba50-a7d84fd80d69","html_url":"https://github.com/r-lib/rprojroot","commit_stats":{"total_commits":662,"total_committers":13,"mean_commits":50.92307692307692,"dds":0.5226586102719033,"last_synced_commit":"004d5bed838695aa7d1a83923ab619bd38ffc84b"},"previous_names":["krlmlr/rprojroot"],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frprojroot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frprojroot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frprojroot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frprojroot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/rprojroot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248365247,"owners_count":21091751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:02:06.884Z","updated_at":"2025-12-12T01:05:39.384Z","avatar_url":"https://github.com/r-lib.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput:\n  github_document:\n    html_preview: false\n---\n\n\u003c!-- README.md and index.md are generated from README.Rmd. Please edit that file. --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\nset.seed(20230702)\n\nclean_output \u003c- function(x, options) {\n  # Side effect\n  usethis::use_build_ignore(\"index.md\")\n\n  x \u003c- gsub(\"0x[0-9a-f]+\", \"0xdeadbeef\", x)\n  x \u003c- gsub(\"dataframe_[0-9]*_[0-9]*\", \"      dataframe_42_42      \", x)\n  x \u003c- gsub(\"[0-9]*\\\\.___row_number ASC\", \"42.___row_number ASC\", x)\n\n  index \u003c- x\n  index \u003c- gsub(\"─\", \"-\", index)\n  index \u003c- strsplit(paste(index, collapse = \"\\n\"), \"\\n---\\n\")[[1]][[2]]\n  writeLines(index, \"index.md\")\n\n  x \u003c- fansi::strip_sgr(x)\n  x\n}\n\noptions(cli.num_colors = 256)\n\nlocal({\n  hook_source \u003c- knitr::knit_hooks$get(\"document\")\n  knitr::knit_hooks$set(document = clean_output)\n})\n\nrlang::local_interactive(FALSE)\n```\n\n# [rprojroot](https://rprojroot.r-lib.org/)\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![rcc](https://github.com/r-lib/rprojroot/workflows/rcc/badge.svg)](https://github.com/r-lib/rprojroot/actions)\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/rprojroot)](https://cran.r-project.org/package=rprojroot)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/rprojroot/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/rprojroot?branch=main)\n\u003c!-- badges: end --\u003e\n\nThis package helps accessing files relative to a *project root* to [stop the working directory insanity](https://gist.github.com/jennybc/362f52446fe1ebc4c49f).\nIt is a low-level helper package for the [here](https://here.r-lib.org/) package.\n\n```{r}\nlibrary(rprojroot)\n```\n\n\n## Example\n\nThe rprojroot package works best when you have a \"project\": all related files contained in a subdirectory that can be categorized using a strict criterion.\nLet's create a package for demonstration.\n\n```{r}\ndir \u003c- tempfile()\npkg \u003c- usethis::create_package(dir)\n```\n\nR packages satisfy the `is_r_package` criterion.\nA criterion is an object that contains a `find_file()` function.\nWith `pkg` as working directory, the function works like `file.path()`, rooted at the working directory:\n\n```{r}\nsetwd(pkg)\nis_r_package\nis_r_package$find_file()\nis_r_package$find_file(\"tests\", \"testthat\")\n```\n\nThis works identically when starting from a subdirectory:\n\n```{r}\nsetwd(file.path(pkg, \"R\"))\nis_r_package$find_file()\nis_r_package$find_file(\"tests\", \"testthat\")\n```\n\nThere is one exception: if the first component passed to `find_file()` is already an absolute path.\nThis allows safely applying this function to paths that may be absolute or relative:\n\n```{r}\nsetwd(file.path(pkg, \"R\"))\npath \u003c- is_r_package$find_file()\nis_r_package$find_file(path, \"tests\", \"testthat\")\n```\n\n\nAs long as you are sure that your working directory is somewhere inside your project, you can retrieve the project root.\n\n\n## Installation and further reading\n\nInstall the package from CRAN:\n\n``` r\ninstall.package(\"rprojroot\")\n```\n\nSee the [documentation](https://rprojroot.r-lib.org/articles/rprojroot.html) for more detail.\n\n---\n\n## Code of Conduct\n\nPlease note that the rprojroot project is released with a [Contributor Code of Conduct](https://rprojroot.r-lib.org/CODE_OF_CONDUCT.html).\nBy contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Frprojroot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Frprojroot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Frprojroot/lists"}