R scripts and site wide variables?

LabKey Support Forum
R scripts and site wide variables? Ben Bimber  2010-04-02 08:40
Status: Closed
 
it would be convenient if certain params were consistent across all our graphs in the EHR. some of this is as simple as coloring on headers. is there a good approach to standardize this? would i write one r script that sets these variables then include it in other scripts?

if that is a viable approach, where is the least obtrusive place to store this script? i wouldnt want it associated with an actual query since there's no reason for a user to see it. i'm writing this as a file based module.
 
 
Karl Lum responded:  2010-04-15 14:10
Hi Ben,

I think the approach would be to consolidate shared code into a script and then include that script in any dependent code.

Unfortunately the shared script needs to live in the same folder as the dependent script and there isn't a way currently to prevent the shared script from appearing in the query view menu.

We can perhaps look into a way for module authors to use shared scripts but control their visibility in the UI.

I also discovered another problem with shared scripts in file based modules that would prevent their use, so I'll need to fix this for 10.2 before you can take advantage of them. I've opened the following but to track: https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=10077
 
Ben Bimber responded:  2010-04-15 14:18
ok, thanks. to get around the issue of making R views that do not show up to users, i have created a dummy query called private.sql. i put my private R scripts under this. i think i should be able to call these from other R scripts without users bumping into them, right?

the reason i asked about XML wrappers (another thread) for file-based R scripts was to set these sort of params: visibility, whether it runs as a pipeline, etc.
 
Karl Lum responded:  2010-04-15 16:30
That sounds like it should work, hopefully you don't run into the problem outlined in 10077. Let me know if you run into issues and I can help troubleshoot or find a workaround.