Closed jankowtf closed 3 years ago
Nothing like this is currently possible. Here I'd just suggest doing the cores
calculation within R. You could even create a wrapper function for calls to config::get()
that handles computed values like this one.
Thanks, I like the idea of the wrapper function! That way you do get a complete picture of all configs by simply looking at the YAML file and that's all we want for now.
If this function is added, do you mind posting an answer to this SO post? https://stackoverflow.com/questions/56284043/self-referential-values-in-an-r-config-file
@rappster, I think my code using glue is like the wrapper function. But if you have a better design, I'll happily accept your answer.
Closing this issue due to inactivity. It also seems there is a reasonable workaround to use a wrapper function, OR to compute the values in the R script instead of the config file.
In dotenv, you can reference values from the same script with this syntax:
value1="10"
value2="${value1}"
@andrie , would you consider something along those lines for config
? It would be very useful in some situations.
EDIT: I just saw this package gonfig, and it seems to solve elegantly the issue, it would be great if config
incorporates that.
My team is successfully using {config} to stay on top of different client configurations and we're loving it! Especially the inheritance feature is awesome and saves a lot of typing.
Now we were wondering if there is any way to specify values that are referencing other values within the same YAML script.
The use case behind it is to have a single point of truth for all configs as opposed to defining dynamic/linked configs in some other R function(s) (where they might easily be overlooked at some point).
We thought about something like
or ideally: