ram_10 0 Newbie Poster

I'm fairly new to R and I'm trying to stack three plots over each other to study the diversity of each plot from one another. Being a newbie to R I still haven't managed to find a solution. I've tried the ggplot and multiplot but failed to accomplish the task. maybe the header in my text file is the problem or I'm not even seeing the problem clearly! It'd be of great help if anyone can advise me in this regard..

my script is as follow:

defects <- read.table(file="C:/_____.txt",header=TRUE)
        squareX <- c()        
        squareY <- c()        

        distance <- c(0 ,17.0 , 17.5,34.5 , 35.0,52.0 , 52.5,69.5 , 70.0,87.0 ,    87.5,104.5 , 105.0,122.0 , 122.5,139.5) 
    square_beginning <- distance[seq(1,length(distance),2)] 

        for ( i in 1:length(defects$x)){ 

            for (e in square_beginning){
                if (defects$x[i]>e & defects$x[i]<e+17.5) {
                squareX[i] <- e/17.5+1 
            }
                if (defects$y[i]>e & defects$y[i]<e+17.5) {
                squareY[i] <- e/17.5+1
            }
        }
    }

defects<- cbind(defects,squareX,squareY)
#plot (defects)

cont <- read.table(file="C:/____.txt",header=TRUE)
squareX <- c()         
squareY <- c()         

distance <- c(0 ,17.0 , 17.5,34.5 , 35.0,52.0 , 52.5,69.5 , 70.0,87.0 , 87.5,104.5 , 105.0,122.0 , 122.5,139.5) 
square_beginning <- distance[seq(1,length(distance),2)] 

for ( i in 1:length(cont$x)){ 

    for (e in square_beginning){  
        if (cont$x[i]>e & cont$x[i]<e+17.5) {
        squareX[i] <- e/17.5+1 
        }
        if (cont$y[i]>e & cont$y[i]<e+17.5) {
        squareY[i] <- e/17.5+1
        }
    }
}
par(mo=c(1,2))
plot(defects, main="test 1")
plot(cont, main="test 2")