-
Notifications
You must be signed in to change notification settings - Fork 159
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
Feature - devtools::use_package and tidyverse style functions #258
Comments
This would be very handy! Please keep in mind the CRAN policy:
|
@KentonWhite it's interesting they have this policy when tools like |
I think the user issuing this command with the sole intent of writing to the system would fall under the exceptions. It's not like it's a possibly unexpected side effect. |
I agree. The simplest way to be compliant is ask the user for confirmation before making the change :) |
Pseudocode:
|
To extend this logic and help ease workflow, I can also think of other |
Rather than having specific functions for each, what if was a general configuration function:
|
@KentonWhite I wanted to make separate pipable verbs which will work well in the
|
The pipe operator takes the output of the lefthand side and inserts it as the first argument to the righthand side, what do you plan to pass between the functions? And if you don't pass anything, why bother piping? Not typing the pipe is even shorter ;-) Also, if you just once need to override a setting then I think the original |
In my 2nd example:
I want to be able to take actions on the I also think the pipe makes code much more readable than operators, but that's just my personal preference. I agree with the statements about the temporary change (for 1 runtime) vs permanent change. Summarizing our discussion so far, we could have the following:
|
But how would the last function in the chain know it is the last function? Put differently, if every function passes the full config, how would each function know whether to write the config to disk or not? The pipe operator is just a nice syntactic sugar for this: loadcache_on(
munge_off(
loaddata_off(
reload_project(
loadcache_off(
munge_on(
loaddata_on()
)
)
)
)
)
) There is nothing magical going on to pass knowledge about functions inside or outside the current function. I think a better approach for your that example would be like this: # Set config permanently to use cache only
update.config(
data.loading = FALSE,
munging = FALSE,
cache.loading = TRUE
)
# Reload once from data
reload.project(
data.loading = TRUE,
munging = TRUE,
cache.loading = FALSE
) |
It's not to say I don't like the idea, but the added value of the piping construction is not clear to me. But if you have an elegant solution then I'm open for it :-) I realise I can be a bit stubborn and strongly opinionated at times ;-) |
Also, we should add a |
@Hugovdberg , I always up for a debate over ideas; if my ideas can pass the muster of smarter folks like you two, then I know it's a good idea. Keep it coming!
I don't know, tbh. In my head, things are still at a conceptual level - I haven't put thought into the actual code structure yet. While I truly (deeply) love pipes, I can agree that your proposal of:
achieves the intent of my needs. Let's go with this, along with an |
Report an Issue / Request a Feature
I'm submitting a (Check one with "x") :
Issue Severity Classification -
(Check one with "x") :
Expected Behavior
An easy console driven method to quickly add libraries to
global.dcf
, which would utilize autocomplete for the package names.Current Behavior
Today, as we work on the projects, adding a library to the
global.dcf
file is a manual process. When many.R
files are open, and the open folder is different, it's a cumbersome workflow to openglobal.dcf
and add the library name without any autocomplete option. (Results in spelling mistakes like I did today -rtsne
instead ofRtsne
.Possible Solution
Something along the lines of the
devtools::use_package()
which can be called from command line as well as will autocomplete package names while typing <read about it>Example usage: from the R console, call
ProjectTemplate::add_package(lattice)
changes theglobal.dcf
from this:to this:
If the package already exists in the list, then the user can be notified and no actions taken.
The text was updated successfully, but these errors were encountered: