library(data.table) library(ggplot2) setwd("D:\\Documents\\uoa\\EngSci\\Teaching\\ENGSCI355\\2017\\Labs\\Pages\\SimpleHealthClinic") conn<-file("Lab1_SteadyState-WaitingRoomLogger.log",open="rt") #setwd("D:\\Documents\\uoa\\EngSci\\Teaching\\ENGSCI355\\2017\\Labs\\Pages\\SHCScheduledAppointments") #conn<-file("Lab2_Extended-WalkUpWaitingTimeLogger.log",open="rt") lines = readLines(conn) close(conn) start <- grep("SimTime", lines) mark <- vector('integer', length(lines)) mark[start] <- 1 mark <- cumsum(mark) tables = split(lines, mark) tables = tables[2:length(tables)] # split the data for reading df <- lapply(tables, function(.data){ .input <- read.table(textConnection(.data), skip=2, , sep="\t", header=TRUE) attr(.input, 'name') <- .data[2] # save the name .input }) for (t in 1:length(tables)) { m = dim(df[[t]])[1] df[[t]] = df[[t]][2:m,] } all_data = rbindlist(df) colnames(all_data)[1] = "SimTime" colnames(all_data)[2] = "Queue.Length" colnames(all_data)[3] = "Max.Queue.Length" colnames(all_data)[4] = "Avg.Queue.Length" plotdata = all_data[all_data$SimTime >= 1512,] plotdata$SimTime = as.numeric(as.character(plotdata$SimTime)) ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$Max.Queue.Length)) + geom_point(colour="red") dev.new() #ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$Avg.Queue.Length)) + ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$Queue.Length)) + #geom_point(colour="red") + geom_line(colour="red") + #scale_y_continuous(limits=c(0,1.5)) + geom_vline(xintercept=(1512+0*168)) + geom_vline(xintercept=(1512+1*168)) + geom_vline(xintercept=(1512+2*168)) + geom_vline(xintercept=(1512+3*168)) + geom_vline(xintercept=(1512+4*168)) + geom_vline(xintercept=(1512+5*168)) + geom_vline(xintercept=(1512+6*168)) + geom_vline(xintercept=(1512+7*168)) + geom_vline(xintercept=(1512+8*168)) + geom_vline(xintercept=(1512+9*168)) + geom_vline(xintercept=(1512+10*168))