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
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
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
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
___
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
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
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
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
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
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
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
11 matches
Mail list logo