Re: [R] Plot step function

2016-02-06 Thread Göran Broström
On 2016-02-06 19:23, David Winsemius wrote: On Feb 6, 2016, at 4:11 AM, jupiter wrote: Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? There is a stepfun function and an associated plotting method: y0 <- c(rep(0,3),re

Re: [R] Plot step function

2016-02-06 Thread David Winsemius
> On Feb 6, 2016, at 4:11 AM, jupiter wrote: > > Hi, > > I am just starting to learn R, sorry for asking a simple question. How can > plot a line x <= 0 y = 0, x > 0 y = 1? There is a stepfun function and an associated plotting method: y0 <- c(rep(0,3),rep(1,3)) sfun0 <- stepfun(-2:2, y0,

Re: [R] Plot step function

2016-02-06 Thread Duncan Murdoch
On 06/02/2016 7:11 AM, jupiter wrote: Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? There are lots of ways. One is curve(ifelse(x < 0, 0, 1), from=-2, to=2) This isn't perfectly vertical at x=0; a more accurate approac

[R] Plot step function

2016-02-06 Thread jupiter
Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? Thank you. - j [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see htt