Re: [R] definition of a function

2008-10-28 Thread Berwin A Turlach
G'day George, On Wed, 29 Oct 2008 06:21:37 +0200 KARAVASILIS GEORGE <[EMAIL PROTECTED]> wrote: > Hello, R subscribers. > I would like to define a function like this one: > Fun <- function(x)sin(x)/x > with value 1 at x=0. How can I do that? Fun <- function(x) ifelse(x==0, 1, sin(x)/x) > Is

Re: [R] definition of a function

2008-10-28 Thread Jorge Ivan Velez
Dear George, Perhaps redefining Fn as Fun2 <- function(x) ifelse(x==0,1,sin(x)/x) could help. Now, for the symbolic part (I'm not sure if understood correctly), try ?curve as follows: curve(Fun2(x),-10,10) HTH, Jorge On Wed, Oct 29, 2008 at 12:21 AM, KARAVASILIS GEORGE <[EMAIL PROTECTED]>wr

[R] definition of a function

2008-10-28 Thread KARAVASILIS GEORGE
Hello, R subscribers. I would like to define a function like this one: Fun <- function(x)sin(x)/x with value 1 at x=0. How can I do that? Is there a way to plot it "symbolically", without using x as a vector? e.g. x <- seq(from=-10, to=10, length=100) plot(x, Fun(x)) Thank you in advance. ___