Re: [R] generate simple function with pre-defined constants

2013-06-09 Thread Liviu Andronic
-Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf >> Of Liviu Andronic >> Sent: Thursday, June 06, 2013 8:00 AM >> To: r-help@r-project.org Help >> Subject: Re: [R] generate simple function with

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Joshua Wiley
On Thu, Jun 6, 2013 at 9:05 AM, William Dunlap wrote: > > I said the force was 'required' in the sense that without it > the function will fail to do what you want in some situations. With the Force on your side, functions always do what you want. > > Bill Dunlap > Spotfire, TIBCO Software > wdu

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Mark Leeds
il.com] > *Sent:* Thursday, June 06, 2013 8:57 AM > *To:* William Dunlap > *Cc:* Liviu Andronic; r-help@r-project.org Help > *Subject:* Re: [R] generate simple function with pre-defined constants > > ** ** > > hi bill: I understand what you're doing but, atleast for

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread William Dunlap
TIBCO Software wdunlap tibco.com From: Mark Leeds [mailto:marklee...@gmail.com] Sent: Thursday, June 06, 2013 8:57 AM To: William Dunlap Cc: Liviu Andronic; r-help@r-project.org Help Subject: Re: [R] generate simple function with pre-defined constants hi bill: I understand what you're do

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Mark Leeds
boun...@r-project.org] > On Behalf > > Of Liviu Andronic > > Sent: Thursday, June 06, 2013 8:00 AM > > To: r-help@r-project.org Help > > Subject: Re: [R] generate simple function with pre-defined constants > > > > On Thu, Jun 6, 2013 at 4:48 PM, Liviu Andronic

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread William Dunlap
CO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Liviu Andronic > Sent: Thursday, June 06, 2013 8:00 AM > To: r-help@r-project.org Help > Subject: Re: [R] generate simple func

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Pascal Oettli
Hi, I am not sure what you are looking for. Here are some examples: foo <- function(a,b,x) a + b*x > foo function(a,b,x) a + b*x a <- 2 b <- 3 x <- 0:10 > foo(a,b,x) [1] 2 5 8 11 14 17 20 23 26 29 32 Or library(polynom) p1 <- polynomial(c(a,b)) > p1 2 + 3*x f1 <- as.function(p1) > f1(

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Liviu Andronic
On Thu, Jun 6, 2013 at 5:03 PM, arun wrote: > HI, > Not sure I understand your question: > a <- 2 > b <- 3 > f1<- function(x) a+b*x > I don't want the function to depend on the objects a and b, but instead use the values of those objects (I do this within a function). Liviu > f1(2) > #[1] 8

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread arun
HI, Not sure I understand your question:  a <- 2  b <- 3  f1<- function(x) a+b*x  f1(2) #[1] 8  f1(3) #[1] 11  f<- function(x) 2+3*x  f(2) #[1] 8  f(3) #[1] 11 A.K.   sessionInfo() R version 3.0.0 (2013-04-03) Platform: x86_64-unknown-linux-gnu (64-bit) locale:  [1] LC_CTYPE=en_CA.UTF-8   L

Re: [R] generate simple function with pre-defined constants

2013-06-06 Thread Liviu Andronic
On Thu, Jun 6, 2013 at 4:48 PM, Liviu Andronic wrote: > Dear all, > Given: > a <- 2 > b <- 3 > > I'd like to obtain the following function: > f <- function(x) 2 + 3*x > > but when I do this: > f <- function(x) a + b*x > ##f > ##function(x) a + b*x > > the 'a' and 'b' objects do not get evaluated t