[Rd] S4 class, passing argument names to function, modify original
Hello, an S4 class "Foo" is defined with a setter, $. For several reasons, the setter calls a function, .foo.update(). However, bypassing the argument names of the setter does not work. Question 1: Why not and how can I fix this? Question 2: What is the way to define either the function or the setter to modify the original object (not returning the modified copy of it an overwrite the original by assignment)? Thanks, Sören setClass("Foo", representation( N = "numeric" ), prototype( N = 1 ) ) .foo.update <- function(object, ...) { args <- list(...) for (i in slotNames("Foo")[pmatch(names(args), slotNames("Foo"), nomatch=0)]) { slot(object, i) <- args[[i]] # indeed more to do here return(object) } } setReplaceMethod("$", "Foo", function(x, name, value) { x <- .foo.update(x, name=value) x } ) x <- new("Foo") x x$N <- 99 x # NULL __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] S4 Slot assignment within function
Is there a simple way to assign values to S4 slots from within a function? Doing this doesn't work: > assign_slot<-function(x){ assign("OBJECT@slot",x,envir=parent.env(environment()) } >assign_slot(x) All I get from this is a new object with the name OBJECT@slot, the slot assignment of OBJECT doesn't change. I have thought about solutions such as eval(parse()) to pull this off, but would prefer not to ugly up the code. Thoughts?? I have searched rather thoroughly, but it is possible I overlooked something. If I did, apologies. -Brian -- View this message in context: http://r.789695.n4.nabble.com/S4-Slot-assignment-within-function-tp3572077p3572077.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] C-Side: Applying a function (given as param) to data (given as param)
On Fri, Jun 03, 2011 at 11:14:39AM -0500, Douglas Bates wrote: > On Fri, Jun 3, 2011 at 5:17 AM, oliver wrote: > > Hello, > > > > I'm implementing a package (C-extension), > > where one function gets data and a function > > that needs to be applied to the data. > > > > I want to apply the function to (parts of) > > the data on the C-side. > > > > 1) how do I apply a function (given via SEXP) to data > > 2) how do I select parts of the data (also provided via SEXP)? > > Not to be facetious but you begin by reading the "Writing R Extensions" > manual. I already read inside it. If there would be no question open i would not have registered to this mailing list and woulod not have asked that question. Obviously my question was not answered in the "Writing R Extensions", so if you can give me a hint this would be nice. > > An alternative is to read the vignette Rcpp-Introduction available as > http://dirk.eddelbuettel.com/code/rcpp/Rcpp-introduction.pdf and soon I use C, not C++. But maybe it helps too. I already created my own package with R and C successfully some days ago. But so far I did not used fucntion pointers coming in via SEXP parameters. And that was my specific question. > to be in The R Journal. They show an explicit example of apply in > compiled code (C++ using the Rcpp structures, in their case). As just mentioned: I already created successfully a C-extension for R. But I would like to know, how to call a function that I get via SEXP as parameter. How can I find out the function definition, for example the arity of the function and which arguments a function uses. The problem is, that the C-standard (at least the first ANSI-C standard) does not guarantee portability for C-pointers. To be portable, for example the function pointer you use must definitely be of same type as the function you use. So I need to know how I can use the SEXP-function pointers. To be more concrete, this is how my function's API looks like at the moment: SEXP movapply( SEXP data, SEXP width, SEXP func ) { /* some code */ return ( result ); } data will be vector or list or matrix width will be int value (I think vector of length 1) func will be a function pointer of the type that is given as argument I don't know on which kind of pointer to cast. I think I will cast to a pure C-type, but then all data also must match to the function definition. What if the function wants to work on integer, but the data is double? Somehow this must be handled, and I think the experts here can just point me directly to some kind of docs or maybe older postinmgs here, which explain this? Ciao, Oliver __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 Slot assignment within function
On 11-06-03 5:03 PM, mcguirebc wrote: Is there a simple way to assign values to S4 slots from within a function? Doing this doesn't work: assign_slot<-function(x){ assign("OBJECT@slot",x,envir=parent.env(environment()) } assign_slot(x) All I get from this is a new object with the name OBJECT@slot, the slot assignment of OBJECT doesn't change. I have thought about solutions such as eval(parse()) to pull this off, but would prefer not to ugly up the code. Thoughts?? I have searched rather thoroughly, but it is possible I overlooked something. If I did, apologies. I haven't tried this, but I would expect OBJECT@slot <<- x to work, assuming OBJECT already exists somewhere outside the function but in its environment. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] C-Side: Applying a function (given as param) to data (given as param)
On 11-06-03 4:19 PM, oliver wrote: On Fri, Jun 03, 2011 at 11:14:39AM -0500, Douglas Bates wrote: On Fri, Jun 3, 2011 at 5:17 AM, oliver wrote: Hello, I'm implementing a package (C-extension), where one function gets data and a function that needs to be applied to the data. I want to apply the function to (parts of) the data on the C-side. 1) how do I apply a function (given via SEXP) to data 2) how do I select parts of the data (also provided via SEXP)? Not to be facetious but you begin by reading the "Writing R Extensions" manual. I already read inside it. If there would be no question open i would not have registered to this mailing list and woulod not have asked that question. Obviously my question was not answered in the "Writing R Extensions", so if you can give me a hint this would be nice. An alternative is to read the vignette Rcpp-Introduction available as http://dirk.eddelbuettel.com/code/rcpp/Rcpp-introduction.pdf and soon I use C, not C++. But maybe it helps too. I already created my own package with R and C successfully some days ago. But so far I did not used fucntion pointers coming in via SEXP parameters. And that was my specific question. to be in The R Journal. They show an explicit example of apply in compiled code (C++ using the Rcpp structures, in their case). As just mentioned: I already created successfully a C-extension for R. But I would like to know, how to call a function that I get via SEXP as parameter. How can I find out the function definition, for example the arity of the function and which arguments a function uses. You should almost certainly do this in R, not in C. If you are doing it in C code you'll just be duplicating the implementation from R, and your code will break if that implementation ever changes. In R you use formals(fn) to extract the function header. The problem is, that the C-standard (at least the first ANSI-C standard) does not guarantee portability for C-pointers. To be portable, for example the function pointer you use must definitely be of same type as the function you use. So I need to know how I can use the SEXP-function pointers. They are not function pointers, they are pointers to R objects. Duncan Murdoch To be more concrete, this is how my function's API looks like at the moment: SEXP movapply( SEXP data, SEXP width, SEXP func ) { /* some code */ return ( result ); } data will be vector or list or matrix width will be int value (I think vector of length 1) func will be a function pointer of the type that is given as argument I don't know on which kind of pointer to cast. I think I will cast to a pure C-type, but then all data also must match to the function definition. What if the function wants to work on integer, but the data is double? Somehow this must be handled, and I think the experts here can just point me directly to some kind of docs or maybe older postinmgs here, which explain this? Ciao, Oliver __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] C-Side: Applying a function (given as param) to data (given as param)
Oliver, For an example of moving averages, take a look at the C source of the xts and TTR packages. The sources are browsable on R-forge. In short, REAL etc are functions to extract the data of an SEXP. They need to match the types coming in. So your C needs to check the type and branch accordingly. It is all in the guide as well as in working example code in R sources as well as many hundreds of package sources. You have access to it all, so spend the time just reading the sources is my recommendation. Best, Jeff Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com www.lemnica.com On Jun 3, 2011, at 3:19 PM, oliver wrote: > On Fri, Jun 03, 2011 at 11:14:39AM -0500, Douglas Bates wrote: >> On Fri, Jun 3, 2011 at 5:17 AM, oliver wrote: >>> Hello, >>> >>> I'm implementing a package (C-extension), >>> where one function gets data and a function >>> that needs to be applied to the data. >>> >>> I want to apply the function to (parts of) >>> the data on the C-side. >>> >>> 1) how do I apply a function (given via SEXP) to data >>> 2) how do I select parts of the data (also provided via SEXP)? >> >> Not to be facetious but you begin by reading the "Writing R Extensions" >> manual. > > I already read inside it. > If there would be no question open i would not have registered to this > mailing list > and woulod not have asked that question. > Obviously my question was not answered in the "Writing R Extensions", > so if you can give me a hint this would be nice. > > >> >> An alternative is to read the vignette Rcpp-Introduction available as >> http://dirk.eddelbuettel.com/code/rcpp/Rcpp-introduction.pdf and soon > > I use C, not C++. > > But maybe it helps too. > > I already created my own package with R and C successfully some days ago. > > But so far I did not used fucntion pointers coming in via SEXP parameters. > > And that was my specific question. > > > > >> to be in The R Journal. They show an explicit example of apply in >> compiled code (C++ using the Rcpp structures, in their case). > > > As just mentioned: I already created successfully a C-extension for R. > > But I would like to know, how to call a function that I get via > SEXP as parameter. How can I find out the function definition, > for example the arity of the function and which arguments > a function uses. > > The problem is, that the C-standard (at least the first ANSI-C standard) > does not guarantee portability for C-pointers. > To be portable, for example the function pointer you use must > definitely be of same type as the function you use. > > So I need to know how I can use the SEXP-function pointers. > > > To be more concrete, this is how my function's API looks like > at the moment: > > SEXP movapply( SEXP data, SEXP width, SEXP func ) > { > /* some code */ > > return ( result ); > } > > > > data will be vector or list or matrix > width will be int value (I think vector of length 1) > func will be a function pointer of the type that is given as argument > > I don't know on which kind of pointer to cast. > I think I will cast to a pure C-type, but then all data also must > match to the function definition. > > What if the function wants to work on integer, but the data is double? > > Somehow this must be handled, and I think the experts here can just point me > directly to some kind of docs or maybe older postinmgs here, which explain > this? > > > Ciao, > Oliver > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 Slot assignment within function
On 06/03/2011 02:03 PM, mcguirebc wrote: Is there a simple way to assign values to S4 slots from within a function? Doing this doesn't work: assign_slot<-function(x){ assign("OBJECT@slot",x,envir=parent.env(environment()) } assign_slot(x) All I get from this is a new object with the name OBJECT@slot, the slot assignment of OBJECT doesn't change. I have thought about solutions such as eval(parse()) to pull this off, but would prefer not to ugly up the code. Thoughts?? I have searched rather thoroughly, but it is possible I overlooked something. If I did, apologies. Maybe you're looking for ?ReferenceClasses rather then S4 classes? Martin -Brian -- View this message in context: http://r.789695.n4.nabble.com/S4-Slot-assignment-within-function-tp3572077p3572077.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 class, passing argument names to function, modify original
On 06/04/2011 03:07 AM, soeren.vo...@uzh.ch wrote: Hello, an S4 class "Foo" is defined with a setter, $. For several reasons, the setter calls a function, .foo.update(). However, bypassing the argument names of the setter does not work. Question 1: Why not and how can I fix this? Question 2: What is the way to define either the function or the setter to modify the original object (not returning the modified copy of it an overwrite the original by assignment)? Thanks, Sören setClass("Foo", representation( N = "numeric" ), prototype( N = 1 ) ) .foo.update<- function(object, ...) { args<- list(...) for (i in slotNames("Foo")[pmatch(names(args), slotNames("Foo"), nomatch=0)]) { slot(object, i)<- args[[i]] # indeed more to do here return(object) } } Since names(args) is 'name', and 'name' is not a slot of 'Foo', the return of pmatch is 0 and .foo.update returns NULL. Put return(object) outside the for loop. setReplaceMethod("$", "Foo", function(x, name, value) { x<- .foo.update(x, name=value) here your intention is that name=value to be substituted with N=99, but you end up with name=99. You could arrange to parse this correctly, but this isn't usually what you _want_ to do and I don't really understand what you're trying to accomplish. Maybe .foo.update <- function(object, name, value, ...) { slot(object, name) <- value ## some other stuff object } Hope that helps a bit. Martin x } ) x<- new("Foo") x x$N<- 99 x # NULL __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Interfacing a C++ class
Hello Apologies for cross-posting, the discussion should (if) go to R-devel, but I also want to reach the rcpp-devel people. My C++ class FOO is a module available through Rcpp, and it works fine and is -- so far -- bug free. With trying to further develop my R package, I thought it was a good idea to interface my C++ workhorse FOO with an S4 class Foo. After some long and not always insightful trip through S4 classes and methods, I am not sure if I am on the right way of thinking and designing. Since there is no local assistance available, could you help to make things clearer? Just a brief outline: FOO is the C++ object, and Foo should be the S4 class. If the user creates an object, say bar, from class Foo, the creation process automatically makes a new FOO object relating to bar in that a unique name of the FOO instance is stored in a slot of bar. All the user then has to do is modify bar by simple assignments. The getters and setters ("$", "[") are set up and work. Each modification goes in hand with assigning new values to bar as well as updating the FOO object through available setters from FOO. So far, this way has brought me to about 100 lines, but now I read about ReferenceClasses and was wondering, if there is a much easier way of achieving my goals. Moreover, I was not sure any longer if my goals make sense or if a more advanced programmer would do it totally different (and could share some structural thinking on their approach). The idea behind my way of doing was based upon several considerations. First, a "classical" R object would not confuse users, as I assume users of my package to be rather non-skilled (and not willing to change that). Second, I want to create a properly programmed package for distribution on CRAN and publication, eventually. Third, I want to save objects across sessions. So if a user restores a session, a simple command, say, restore(), would do the trick to build all the related C++ objects again. However, I admit that I still have not figured out how to automatically clean up the workspace correctly before leaving a session, wanted or unwanted, that is, clean up memory before leaving home. Fourth, pure arithmetic check is done in C++, however, semantic check *should* be left to R, and the validity and class routines seem to be perfect for this. Fifth, some work should be done in R, such as the passing of data frames or samples from distributions. I hope to get some structured ideas and hints how to start and/or proceed. Thank you in advance, Sören __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 class, passing argument names to function, modify original
On 04.06.2011, at 15:41, Martin Morgan wrote: > On 06/04/2011 03:07 AM, soeren.vo...@uzh.ch wrote: > >> Hello, an S4 class "Foo" is defined with a setter, $. For several reasons, >> the setter calls a function, .foo.update(). However, bypassing the argument >> names of the setter does not work. Question 1: Why not and how can I fix >> this? Question 2: What is the way to define either the function or the >> setter to modify the original object (not returning the modified copy of it >> an overwrite the original by assignment)? Thanks, Sören >> >> setClass("Foo", >> representation( >> N = "numeric" >> ), >> prototype( >> N = 1 >> ) >> ) >> >> .foo.update<- function(object, ...) { >> args<- list(...) >> for (i in slotNames("Foo")[pmatch(names(args), slotNames("Foo"), >> nomatch=0)]) { >> slot(object, i)<- args[[i]] >> # indeed more to do here >> return(object) >> } >> } > > Since names(args) is 'name', and 'name' is not a slot of 'Foo', the return of > pmatch is 0 and .foo.update returns NULL. Put return(object) outside the for > loop. > >> setReplaceMethod("$", "Foo", >> function(x, name, value) { >> x<- .foo.update(x, name=value) >> x >> } >> ) >> >> x<- new("Foo") >> x >> x$N<- 99 >> x # NULL > > here your intention is that name=value to be substituted with N=99, but you > end up with name=99. You could arrange to parse this correctly, but this > isn't usually what you _want_ to do and I don't really understand what you're > trying to accomplish. Exactly, what I want to parse is "N"=99. To clarify, .foo.update should be the "one" workhorse to do a couple of things depending on arguments on more than one object (see my post on interfacing a C++ class, just some minutes ago). Thus, assigning x@N = 10 (x$N, x["N"]) should not only end up in x (object of class Foo) with value 10, but also should invoke FOO$setN(10) (a setter for the C++ object, not shown here). So far, .foo.update works perfectly and indeed alters the object x, but the setter does not parse the argument name. I tried with quote, substitute, deparse ..., but got none working ... > Maybe > > .foo.update <- function(object, name, value, ...) > { >slot(object, name) <- value >## some other stuff >object > } > > Hope that helps a bit. > > Martin Thanks, Sören __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Interfacing a C++ class
On Jun 4, 2011, at 10:31 AM, soeren.vo...@uzh.ch wrote: > Hello > > Apologies for cross-posting, the discussion should (if) go to R-devel, but I > also want to reach the rcpp-devel people. > > My C++ class FOO is a module available through Rcpp, and it works fine and is > -- so far -- bug free. With trying to further develop my R package, I thought > it was a good idea to interface my C++ workhorse FOO with an S4 class Foo. > After some long and not always insightful trip through S4 classes and > methods, I am not sure if I am on the right way of thinking and designing. > Since there is no local assistance available, could you help to make things > clearer? > > Just a brief outline: > > FOO is the C++ object, and Foo should be the S4 class. If the user creates an > object, say bar, from class Foo, the creation process automatically makes a > new FOO object relating to bar in that a unique name of the FOO instance is > stored in a slot of bar. All the user then has to do is modify bar by simple > assignments. The getters and setters ("$", "[") are set up and work. Each > modification goes in hand with assigning new values to bar as well as > updating the FOO object through available setters from FOO. > It's fairly simple, you just create an external pointer for your object, register "delete obj;" as its finalizer and put it in a slot of your S4 object . Have a look, for example, at rJava. It uses S4 objects with one slot being an external pointer to the object in Java (in your case C++). For a C++ package with external pointers see Acinonyx (aka iPlots eXtreme) - from RCalls.cpp: static void AObjFinalizer(SEXP ref) { if (TYPEOF(ref) == EXTPTRSXP) { AObject *o = static_cast (R_ExternalPtrAddr(ref)); if (o) o->release(); // NOTE: you would probably use delete o; instead } } SEXP A2SEXP(AObject *o) { SEXP xp = R_MakeExternalPtr(o, R_NilValue, R_NilValue); R_RegisterCFinalizerEx(xp, AObjFinalizer, TRUE); return xp; } AObject *SEXP2A(SEXP o) { if (TYPEOF(o) != EXTPTRSXP) Rf_error("invalid object"); return (AObject*) R_ExternalPtrAddr(o); } > So far, this way has brought me to about 100 lines, but now I read about > ReferenceClasses and was wondering, if there is a much easier way of > achieving my goals. Moreover, I was not sure any longer if my goals make > sense or if a more advanced programmer would do it totally different (and > could share some structural thinking on their approach). > ReferenceClasses are very similar - they differ from the approach I described only in that they use an environment for the reference semantics where your would use external pointer to your object. Technically, you could put your external pointer in a reference class object - what you would gain is the ability to store other R objects alongside if you need them. > The idea behind my way of doing was based upon several considerations. First, > a "classical" R object would not confuse users, as I assume users of my > package to be rather non-skilled (and not willing to change that). Second, I > want to create a properly programmed package for distribution on CRAN and > publication, eventually. Third, I want to save objects across sessions. So if > a user restores a session, a simple command, say, restore(), would do the > trick to build all the related C++ objects again. However, I admit that I > still have not figured out how to automatically clean up the workspace > correctly before leaving a session, wanted or unwanted, that is, clean up > memory before leaving home. Again, have a look at rJava (see ?.jcache) - it uses Java object serialization to cache serialized versions of objects (as raw vectors) in the protection part of the pointer which gets serialized by R on save(). Then restoration is automatic: when rJava sees a NULL pointer (that's what the are deserialized too) in the S4 object, it checks whether there is a serialized cache and restores the Java object. Cheers, Simon > Fourth, pure arithmetic check is done in C++, however, semantic check > *should* be left to R, and the validity and class routines seem to be perfect > for this. Fifth, some work should be done in R, such as the passing of data > frames or samples from distributions. > > I hope to get some structured ideas and hints how to start and/or proceed. > > Thank you in advance, > Sören > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Does anybody successfully built latest R on AIX 5.3?
__ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] call / do.call expression too big
I am designing a remote procedure protocol for R, which basically performs a do.call on data and arguments supplied by a client. However, I am experiencing unfortunate behavior of the do.call function. The function do.call seems to serialize all objects in the args list, resulting in an enormous expression, that is then in some way or another returned by many functions. A short example: args <- list(data=cars, formula=dist~speed); do.call("lm",args); One can see that for this small example, the returned 'call' attribute is already huge. Another example: eval(call("cor.test", x=rnorm(100), y=rnorm(100))) I completely understand why this happens, yet I was wondering if there is an alternative to call/do.call that constructs the call in an different way so that the actual call object is somewhat more compact and does not contain all the data that was involved in the function. For example one that attaches the args list in an environment and constructs a call that refers to these objects or something similar. -- View this message in context: http://r.789695.n4.nabble.com/call-do-call-expression-too-big-tp3574335p3574335.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] call / do.call expression too big
Try this: args <- list(data=quote(cars), formula=dist~speed) On Sat, Jun 4, 2011 at 7:49 PM, Jeroen Ooms wrote: > I am designing a remote procedure protocol for R, which basically performs a > do.call on data and arguments supplied by a client. However, I am > experiencing unfortunate behavior of the do.call function. The function > do.call seems to serialize all objects in the args list, resulting in an > enormous expression, that is then in some way or another returned by many > functions. A short example: > > args <- list(data=cars, formula=dist~speed); > do.call("lm",args); > > One can see that for this small example, the returned 'call' attribute is > already huge. Another example: > > eval(call("cor.test", x=rnorm(100), y=rnorm(100))) > > I completely understand why this happens, yet I was wondering if there is an > alternative to call/do.call that constructs the call in an different way so > that the actual call object is somewhat more compact and does not contain > all the data that was involved in the function. For example one that > attaches the args list in an environment and constructs a call that refers > to these objects or something similar. > > > -- > View this message in context: > http://r.789695.n4.nabble.com/call-do-call-expression-too-big-tp3574335p3574335.html > Sent from the R devel mailing list archive at Nabble.com. > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] call / do.call expression too big
> I completely understand why this happens, yet I was wondering if there is an > alternative to call/do.call that constructs the call in an different way so > that the actual call object is somewhat more compact and does not contain > all the data that was involved in the function. For example one that > attaches the args list in an environment and constructs a call that refers > to these objects or something similar. Like this? argn <- lapply(names(args), as.name) names(argn) <- names(args) call <- as.call(c(list(as.name("lm")), argn)) eval(call, args) Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel