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") setwd("D:\\Documents\\uoa\\EngSci\\Teaching\\ENGSCI355\\2017\\Labs\\Pages\\ExtendedHealthClinic") conn<-file("Lab3_Extended-WaitingRoom.log",open="rt") lines = readLines(conn) close(conn) start <- grep("####", 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)) { line1 = trimws(gsub(".*(RUN)", "", tables[t][[1]][[1]])) line2 = trimws(gsub("#\\S*", "", line1)) keys = strsplit(line2, "-") df[[t]]$Config = as.numeric(keys[[1]][[1]]) df[[t]]$Rep = as.numeric(keys[[1]][[2]]) m = dim(df[[t]])[1] df[[t]] = df[[t]][2:m,] } all_data = rbindlist(df) #colnames(all_data)[2] = "Queue.Length" #colnames(all_data)[3] = "Max.Queue.Length" #colnames(all_data)[4] = "Avg.Queue.Length" colnames(all_data)[2] = "WaitingRoom" plotdata = all_data[all_data$Config == 4,] plotdata = plotdata[plotdata$Rep <= 10,] plotdata$SimTime = as.numeric(as.character(plotdata$SimTime)) plotdata$Rep = as.factor(plotdata$Rep) #plotdata = plotdata[plotdata$SimTime < 200,] #ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$Max.Queue.Length,colour=plotdata$Rep)) + geom_point() #dev.new() #ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$Avg.Queue.Length,colour=plotdata$Rep)) + geom_point() ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$Max.Queue.Length,colour=plotdata$Rep)) + geom_point() ggplot(plotdata, aes(x=plotdata$SimTime, y=plotdata$WaitingRoom,colour=plotdata$Rep)) + geom_line()