Re: [R] Function question

2009-09-25 Thread Henrique Dallazuanna
Try this: foo <- function(expr, x){ eval(substitute(expr)) } foo(x^2, 4) foo(x^3-10, 2) On Fri, Sep 25, 2009 at 6:16 PM, njhuang86 wrote: > > Hi. I was wondering how I can write a function that generates the outcome > values for a user specified equation. For example, function(x^2, 4) w

Re: [R] function question

2009-03-20 Thread Wacek Kusnierczyk
ge- > From: Wacek Kusnierczyk [mailto:waclaw.marcin.kusnierc...@idi.ntnu.no] > Sent: Thursday, March 19, 2009 1:03 PM > To: Bert Gunter > Cc: Edna Bell; R help > Subject: Re: [R] function question > > Bert Gunter wrote: > >> Edna: >> >> Please make at le

Re: [R] function question

2009-03-19 Thread Bert Gunter
Not surprising at all -- expected! is.function(vector) ##TRUE -- Bert -Original Message- From: Wacek Kusnierczyk [mailto:waclaw.marcin.kusnierc...@idi.ntnu.no] Sent: Thursday, March 19, 2009 1:03 PM To: Bert Gunter Cc: Edna Bell; R help Subject: Re: [R] function question Bert Gunter

Re: [R] function question

2009-03-19 Thread Wacek Kusnierczyk
Bert Gunter wrote: > Edna: > > Please make at least a minimal effort to answer such questions before > posting. > > is.vector(function(x)x) ## FALSE > as.vector(function(x)x) ## try it > > or even > > is.vector(plot) > > ... or even the surprizing is.vector(vector) vQ ___

Re: [R] function question

2009-03-19 Thread Peter Dalgaard
Patrick Burns wrote: Duncan Murdoch wrote: On 3/19/2009 12:49 PM, Edna Bell wrote: Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? Your question is a little ambiguous (you probably did read that, and probably someone does consider them to be vect

Re: [R] function question

2009-03-19 Thread Gabor Grothendieck
In mathematics that is the case. That is vector v = (v_1, v_2, ..., v_n) can be considered to be the function which maps k to v_k but there is no real relation to this in terms of R classes and objects. On Thu, Mar 19, 2009 at 12:49 PM, Edna Bell wrote: > Dear R Gurus: > > I read somewhere that

Re: [R] function question

2009-03-19 Thread Patrick Burns
Duncan Murdoch wrote: On 3/19/2009 12:49 PM, Edna Bell wrote: Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? Your question is a little ambiguous (you probably did read that, and probably someone does consider them to be vectors), but I think the

Re: [R] function question

2009-03-19 Thread Bert Gunter
Edna: Please make at least a minimal effort to answer such questions before posting. is.vector(function(x)x) ## FALSE as.vector(function(x)x) ## try it or even is.vector(plot) -- Bert Gunter Genentech -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-pr

Re: [R] function question

2009-03-19 Thread Duncan Murdoch
On 3/19/2009 12:49 PM, Edna Bell wrote: Dear R Gurus: I read somewhere that functions are considered vectors. Is this true, please? Your question is a little ambiguous (you probably did read that, and probably someone does consider them to be vectors), but I think the right answer is no: w

Re: [R] function question

2009-02-11 Thread jim holtman
Is this what you want: > x FL number 1 34 4 2 35 3 3 36 7 > cbind(rep(x$FL, x$number), 1) [,1] [,2] [1,] 341 [2,] 341 [3,] 341 [4,] 341 [5,] 351 [6,] 351 [7,] 351 [8,] 361 [9,] 361 [10,] 361 [11,] 361

Re: [R] Function question

2008-10-17 Thread Dimitris Rizopoulos
try uniroot(), e.g., f <- function (x) x^2 uniroot(function(x, a) f(x) - a, c(0, 10), a = 4) I hope it helps. Best, Dimitris dennis11 wrote: Hi, Let's say very simply there is a function: f <- function (x) x^2 which is evaluated with : f(2) Now, I want to do the reverse so I want to no