#set the work directory to where the files are before using the script: setwd("path_to_directory")
# delete all '#' from the data, otherwise it won't read the columns after '#'
# 1 -> MeNB to MeNB
# 2 -> PeNB to PeNB
# 3 -> MeNB to PeNB
# 4 -> PeNB to MeNB
rm(list = ls())

File_name <- readline("Enter the file name:")
File_nameTXT <- paste(File_name,".txt",sep = "")
File_nameCSV <- paste(File_name,"_v2.csv",sep = "")
rawData <- readLines(File_nameTXT)
Table <- read.table(text = rawData, sep = "\t")
Table <- within(Table, V9 <- V1 + V8)

Table[(Table$V6 < 100 & Table$V8 < 100 ),"V9"] <- 1
Table[(Table$V6 >= 100 & Table$V8 >= 100 ),"V9"] <- 2
Table[(Table$V6 < 100 & Table$V8 >= 100 ),"V9"] <- 3
Table[(Table$V6 >= 100 & Table$V8 < 100 ),"V9"] <- 4

HO<-c(Table$V9[1:length(Table$V9)])
UE = table(HO)
write.csv(UE, file = File_nameCSV)