R plot with stairs/steps

By Ramet

stairs plot example

I have a file, say ‘test.txt’ with:

5 80  
3 70  
4 60  

Now I want to create an R plot that looks like stairs/steps: y-value 80 for 5 data points, then y-value 70 for 3 data points and then y-value 60 for 4 data points, something like this:

How could I transform the test.txt to transformed.txt:

80  
80  
80  
80  
80  
70  
70  
70  
60  
60  
60  
60  

on the shell, or, alternatively directly print the plot in R from test.txt.

Source:: http://askubuntu.com/questions/870582/r-plot-with-stairs-steps


Leave a Reply