Hello getdata <- function(p){ fname <- NULL; dl <- list(NULL)#build the sturcture dt <- read.csv(file.path(d,i),header=F) #data frame ret <- builddl(dt,s) #where "s" is a string } how can I get this following function to use fname and dl from the above function without passing them down the chain? builddl <- function(q,s){ fname <- c(fname,s) dl <- list( dl, q) } thanks
On Fri, 26 Mar 2004 21:34:21 -0800 (PST), you wrote:>Hello > >getdata <- function(p){ > fname <- NULL; dl <- list(NULL)#build the sturcture > dt <- read.csv(file.path(d,i),header=F) #data frame > ret <- builddl(dt,s) #where "s" is a string >} > >how can I get this following function to use fname and >dl from the above function without passing them down >the chain? > >builddl <- function(q,s){ > fname <- c(fname,s) > dl <- list( dl, q) >}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 frame ret <- builddl(dt,s) #where "s" is a string } Duncan Murdoch
--- Duncan Murdoch <dmurdoch at pair.com> wrote:> On Fri, 26 Mar 2004 21:34:21 -0800 (PST), you wrote: > > >Hello > > > >getdata <- function(p){ > > fname <- NULL; dl <- list(NULL)#build the > sturcture > > dt <- read.csv(file.path(d,i),header=F) #data > frame > > ret <- builddl(dt,s) #where "s" is a string > >} > > > >how can I get this following function to use fname > and > >dl from the above function without passing them > down > >the chain? > > > >builddl <- function(q,s){ > > fname <- c(fname,s) > > dl <- list( dl, q) > >} > > 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) #datathe 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. hummm> frame > ret <- builddl(dt,s) #where "s" is a string > } > > Duncan Murdoch