[R] Loading .Rdata within an R function

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jul 9 00:25:56 CEST 2010


On 08/07/2010 6:21 PM, Duncan Murdoch wrote:
> On 08/07/2010 3:21 PM, Giles Crane wrote:
>   
>> Colleagues:
>>
>> I am having trouble loading data from within .Rdata file
>> within the environment of a function.  That is,
>> the following always loads to the global environment:
>>
>>    f1 <- function()    {
>>
>>            load("mydata.Rdata")
>>
>>            #  compute with objects from mydata.Rdata.
>>
>>            }
>>
>> I wish to load mydata.Rdata only within the function f1.
>> Perhaps I have misunderstood the capabilities of load(),
>> or the environment concepts.
>>     
>
>
> You didn't specify where you wanted it loaded.  Just add 
> envir=environment() to the call to load.


Sorry, my reply is misleading:  what you did will give the same result 
as what I suggested.

What makes you think it didn't work?

Duncan Murdoch



More information about the R-help mailing list