# How to plot this simple step function? Classic List Threaded 5 messages Open this post in threaded view
|

## How to plot this simple step function?

 Hi everyone, I am trying to graph a step function in R Studio. I just learned about R today and decided to try it!  The following is what I want it to look like. I graphed it using x <- 0:5 y <- c(0, .2, .3, .6, .9, 1.0) plot(x, y, type = "s")   And used Microsoft Paint to get it to how I wanted it to look, but I want to do it in R Studio completely. How can I replicate this image? Also, when do I use the window above the Console? Any incredibly easy tutorials out there to get me started?
Open this post in threaded view
|

## Re: How to plot this simple step function?

Open this post in threaded view
|

## Re: How to plot this simple step function?

 Thank you for your reply! When I copy and paste the code into the Console, I receive several errors! ```plot(x,y,type="n") segments(x[-length(x)],y[-length(x)],x[-1],y[-length(x)]) points(x[-length(x)],y[-length(x)],pch=16) points(x[-1],y[-length(x)],pch=1) ```1) Error in plot(x, y, type = "n") : object 'x' not found > segments(x[-length(x)],y[-length(x)],x[-1],y[-length(x)]) Error in segments(x[-length(x)], y[-length(x)], x[-1], y[-length(x)]) :   object 'x' not found 2)Error in points(x[-length(x)], y[-length(x)], pch = 16) :   object 'x' not found points(x[-1],y[-length(x)],pch=1) 3) Error in points(x[-1], y[-length(x)], pch = 1) : object 'x' not found. What am I doing wrong? :'(