I am writing a code to generate four stimulations and then generate graphs. My code works, but I want instead of generating four graphs I want to combine them all in one graph. How can I do that?
My code:
queueSimulation <- function(arriverate, servrate, endtime) {
    queue = numeric(0)
    arrivetimes = rexp(10000, arriverate)
    servtimes = rexp(10000, servrate)
    clock = 0.0 
    clist=c() 
    qlist=c()
    while(clock <= endtime) {
       if(length(queue) > 0 && queue[1] < arrivetimes[1]) {
          clock = clock + queue[1]
          queue = queue[-1]   
       }   
       else {
          clock = clock + arrivetimes[1]
          queue[length(queue) + 1] = servtimes[1]
          arrivetimes = arrivetimes[-1]
          servtimes = servtimes[-1]
       }   
    #queue_size= length(round(clock, 2))
       clist = c(clist , clock)
       qlist = c(qlist , length(queue))
    }   
    a<-data.frame(time=clist , qsize=qlist)
    print(a)
    mean1<-mean(qlist)
    cat("Average :", mean1, "\n")
    plot(a)
}
and calling the function:
queueSimulation(1.0, 5.0, 100) 
queueSimulation(2.0, 4.0, 100)
queueSimulation(2.3, 3.5, 100) 
queueSimulation(4.0, 5.0, 100)
    