-1

I want to represent a discrete line graph similar to this image in r code, please help me. assume any values.

enter image description here

Things the i have tried & the data set is here

bus.stop<-c("Polic Chowk","Regional bus stand","hospital", "Alanpura", "Housing Colony", "PG College", "Ranthambore circle" , "Railway station", "Collectorate", "New Bus stand")

boarding<-c(18,9,15,3,7,1,1,0,0,0)
alighting<-c(0,3,7,5,8,1,13,8,5,4)
load<-c(18,24,38,32,29,27,23,11,4,0)

hous.oton<-data.frame("BusStop" = bus.stop, "Boarding" = boarding, "Alighting"=alighting, "Load"=load)

plot(hous.oton$BusStop,hous.oton$Boarding, type="s")
```
Sork-kal
  • 307
  • 3
  • 10
  • 2
    Please provide the representative dataset with whatever code you have tried. See How to make a great R reproducible example [link](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/16532098#16532098) – UseR10085 Oct 19 '19 at 12:48
  • you can put something together for yourself with `segments()` ... your data set doesn't look *anything* like the plot you've requested - not clear how we would get it into that format ... – Ben Bolker Oct 19 '19 at 15:06

1 Answers1

0

If you just want to draw a stepped line graph, you could probably acquire that with package ggplot2:

library(ggplot2)
ggplot(hous.oton, aes(x=BusStop, y=Boarding, group=1)) + geom_step()

You need to specify group=1, because you only have one observation per bus stop.

For further information, please see, e.g., Creating a cumulative step graph in R .

i4jm03
  • 1