[R] How to source files from a search path?
Don MacQueen
macq at llnl.gov
Sat Feb 13 01:11:07 CET 2010
Well, you still will need Sys.getenv() to get the value of the
environment variable into R.
Are you familiar with the function named list.files() ?
This may do the job:
source( list.files( Sys.getenv('SOMEENVVAR'), pattern='myfilename') )
But I haven't tested it.
-Don
(and your name or affiliation would still be appreciated, as a matter
of R-help etiquette)
At 5:42 PM -0600 2/12/10, blue sky wrote:
>On Fri, Feb 12, 2010 at 5:28 PM, Bert Gunter <gunter.berton at gene.com> wrote:
>> 1. Etiquette on this list is to sign posts with your real name.
>>
>> 2. Please use R's Help facilities (beyond RSiteSearch()) first before
>> posting:
>>
>> ?help.search
>>
>> help.search("environment variable")
>
>I guess you are referring to 'Sys.getenv', which is not what I am looking for.
>
>To restate my question:
>
>How to source a file without specifying the full path, but by deriving
>the file's full path by searching in an environment variable.
>
>Of course, 'Sys.getenv' will be useful if I want to make such a
>function myself. But my question was to look for a better version of
>source().
>
>Are you clear about my question now?
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
>> Behalf Of blue sky
>> Sent: Friday, February 12, 2010 2:55 PM
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] How to source files from a search path?
>>
>> Suppose some environment variable (say MY_R_INC) has a number of
>> paths. I want to source some file relative to some path in $MY_R_INC
>> (just as #include in C++ does, which looks for header file in a number
>> of directories). I RSiteSearch'ed, but I don't find any function that
>> satisfies my need. Could somebody let me know if I overlooked
>> something?
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://*stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>>http://*www.*R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>______________________________________________
>R-help at r-project.org mailing list
>https://*stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
More information about the R-help
mailing list