[R] [FORGED] Plot step function

Rolf Turner r.turner at auckland.ac.nz
Sat Feb 6 19:29:39 CET 2016


On 07/02/16 01:11, 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?

One way:

     plot(c(-1,0,1),c(0,1,1),type="s",xlab="x",ylab="y")

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-help mailing list