-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-R-dominant folder setup #85
Comments
In a structure where your R project sits parallel to a "data" directory, can you use |
The problem isn't documentation, it's #19, #21, #27, and #28 again. In cases where the true root is higher or lower than the Ironically the package has come full circle and is now even worse than the original problem
In fact in your own example project ( So for the original user
In this case |
Thank you for your perspective. It's difficult for me to see what you're requesting, and also the relationship to the original post. What do you mean by "if the |
A
As sda030 said: "...my Rproj files are often pushed into a subfolder called "R-analysis" or something. data folders might be located further up the directory structure." Currently
That's the issue, if this is supposed to work it doesn't. At least not reliably. The presence of sda030 and I are both two sides of the same issue with this. In their case the true project root is one or more levels higher than
The second example also presents a showstopping issue: When the container is built Any time code is shared between people or platforms with different Based on your response that placing a |
Thanks. I'm seeing: fs::dir_create("proj")
brio::write_file("", "proj/test.Rproj")
fs::dir_create("proj/here")
brio::write_file("", "proj/here/.here")
fs::dir_tree("proj", all = TRUE)
#> proj
#> ├── here
#> │ └── .here
#> └── test.Rproj
setwd("proj/here")
fs::dir_tree(all = TRUE)
#> .
#> └── .here
here::here()
#> [1] "/private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here"
here::dr_here()
#> here() starts at /private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here.
#> - This directory contains a file ".here"
#> - Initial working directory: /private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here
#> - Current working directory: /private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here
setwd("..")
fs::dir_tree(all = TRUE)
#> .
#> ├── here
#> │ └── .here
#> └── test.Rproj
here::here()
#> [1] "/private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here"
here::dr_here()
#> here() starts at /private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here.
#> - This directory contains a file ".here"
#> - Initial working directory: /private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj/here
#> - Current working directory: /private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpGQICa8/reprex-e5cf6becf7a7-fishy-coral/proj Created on 2024-01-17 with reprex v2.0.2 One thing to keep in mind is that {here} won't change its opinion if the working directory is changed after the package is loaded. This is intended, and (I believe) has been discussed before. Can you please construct a similar example for your use case? |
This a standard dockerized shiny app. Loading the R Project, in order to have access to version control that includes the dockerfile, sets the working directory to
And this is the diagnostic report:
As you demonstrated the only way to make In the former However if the package were changed so the The difference is one of design philosophy. Whether a package is intended to be pro-user and enable open collaboration or anti-user and lock people in to proprietary practices. Like how Microsoft Office breaks standards and locks people in to their proprietary formats while libreoffice doesn't. |
The here package doesn't descend into subdirectories, I don't see how your use case as I understand it might work with However, it might work with rprojroot, the package that powers the here package: fs::dir_create("parent_dir")
brio::write_file("", "parent_dir/test.Rproj")
fs::dir_create("parent_dir/shiny_app")
brio::write_file("", "parent_dir/shiny_app/server.R")
brio::write_file("", "parent_dir/shiny_app/ui.R")
fs::dir_tree("parent_dir", all = TRUE)
#> parent_dir
#> ├── shiny_app
#> │ ├── server.R
#> │ └── ui.R
#> └── test.Rproj
crit <- rprojroot::has_basename("shiny_app", subdir = "shiny_app")
here <- crit$find_file
setwd("parent_dir")
fs::dir_tree(all = TRUE)
#> .
#> ├── shiny_app
#> │ ├── server.R
#> │ └── ui.R
#> └── test.Rproj
here("ui.R")
#> [1] "/private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/Rtmp82ViI8/reprex-106563780a467-smoky-moose/parent_dir/shiny_app/ui.R"
setwd("shiny_app")
fs::dir_tree(all = TRUE)
#> .
#> ├── server.R
#> └── ui.R
here("ui.R")
#> [1] "/private/var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/Rtmp82ViI8/reprex-106563780a467-smoky-moose/parent_dir/shiny_app/ui.R" Created on 2024-01-22 with reprex v2.0.2 |
My understanding from the documentation was that Going by your example: if |
Have you seen https://here.r-lib.org/articles/here.html#under-the-hood-rprojroot? I believe that the reprex I shared is setting up a project structure similar to the one that you describe. At this stage, I'd say it's worth trying out? |
We R users like to think that our RStudio Project file is in the top folder, and everything else is neatly organized in subfolders. In many research organizations and teams, not everyone uses R (nor is everything in a project about quantitative analysis). Hence, my Rproj files are often pushed into a subfolder called "R-analysis" or something. data folders might be located further up the directory structure. I therefore do not see how here can be of use for me and my colleagues (although I want to). Am I missing obvious solutions, or is this feature that should be added?
The text was updated successfully, but these errors were encountered: