Re: [R] function closure

2013-08-12 Thread Ashwani Rao
> > > glob2rx("*.xml") > > [1] "^.*\\.xml$" > > ** ** > > Bill Dunlap**** > > Spotfire, TIBCO Software > > wdunlap tibco.com > > ** ** > > *From:* Ashwani Rao [mailto:ashwamegh1...@gmail.com] > *Sen

Re: [R] function closure

2013-08-12 Thread William Dunlap
to regular expressions. > glob2rx("*.xml") [1] "^.*\\.xml$" Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Ashwani Rao [mailto:ashwamegh1...@gmail.com] Sent: Monday, August 12, 2013 10:04 AM To: William Dunlap Cc: r-help@r-project.org Subject: Re: [R] functio

Re: [R] function closure

2013-08-12 Thread jim holtman
Try changing the assignment to use "<<-" fileindex <<- fileindex + 1 On Mon, Aug 12, 2013 at 12:44 PM, Ashwani Rao wrote: > Hi, > > Just for fun, I wanted to try function closures. > Here is simple function definition. > The following "generateFiles" function return function "fileGen"

Re: [R] function closure

2013-08-12 Thread Ashwani Rao
Thanks Bill. Can you please tell me why did you change exp "pattern="*.xml"" to pattern="\\.xml$". I know that second one also makes sense. On Mon, Aug 12, 2013 at 9:59 AM, William Dunlap wrote: > Change your 'fileIndex <- fileIndex + 1' to 'fileIndex <<- fileIndex + 1' > so the fileIndex in

Re: [R] function closure

2013-08-12 Thread William Dunlap
Change your 'fileIndex <- fileIndex + 1' to 'fileIndex <<- fileIndex + 1' so the fileIndex in the environment of the call to generateFiles() is altered (instead of creating and forgetting about a variable called fileIndex in the function created by generateFiles. generateFiles <- function(path,