here icon indicating copy to clipboard operation
here copied to clipboard

Feature request: here() that keeps paths short with RProjects

Open bpfree opened this issue 1 year ago • 3 comments

Neat package to have pathnames work across Macs and Windows. Curious if there exists a plan to have here() get integrated with RProjects to keep pathnames short.

For instance RProjects would produce a pathname that would look like: data/a_raw_data/subdirectory/dataset.gpkg.

here::here() for a similar location would produce something like: users/USER/documents/project/data/a_raw_data/subdirectory/dataset.gpkg

Does this make sense? Being able to combine here with RProject would provide a powerful collaborative capability between colleagues using different operating systems.

bpfree avatar Feb 14 '24 21:02 bpfree

Thanks. What is RProjects?

krlmlr avatar Feb 14 '24 21:02 krlmlr

It is a nice feature of RStudio. Many benefits, but a significant one is the ability to have version control with Git and have streamlined pathnames for directories and data. RProjects are often self-contained.

bpfree avatar Feb 15 '24 14:02 bpfree

Are you looking for fs::path_rel() ?

library(here)
#> here() starts at /Users/kirill/git/R/fledge

path <- here::here("R/auto.R")
path
#> [1] "/Users/kirill/git/R/fledge/R/auto.R"

fs::path_rel(path)
#> R/auto.R

Created on 2024-02-15 with reprex v2.1.0

krlmlr avatar Feb 15 '24 14:02 krlmlr