[R] variable scope

Duncan Murdoch dmurdoch at pair.com
Sat Mar 27 16:50:49 CET 2004


On Sat, 27 Mar 2004 07:08:09 -0800 (PST), "Fred J." <phddas at yahoo.com>
wrote :

>> The normal way would be to define builddl() within
>> getdata(), i.e.
>> 
>> getdata <- function(p){
>>   builddl <- function(q,s){
>>     fname <- c(fname,s)
>>     dl <- list( dl, q) 
>>   }
>>   fname <- NULL; dl <- list(NULL)#build the
>> sturcture
>>   dt <- read.csv(file.path(d,i),header=F)  #data
>
>the only problem with this method is that the debug
>package$mtrace will not step into the sub.fun builddl
>becuase it will treat it as one line statement. 

I haven't used the debug package much, but with the standard "debug"
function you can call "debug(builddl)" within the function, after
creating builddl, to turn on debugging.  

Duncan Murdoch




More information about the R-help mailing list