# This R environment comes with all of CRAN preinstalled, as well as many other helpful packages
# The environment is defined by the kaggle/rstats docker image: https://github.com/kaggle/docker-rstats
# For example, here's several helpful packages to load in 

library(ggplot2) # Data visualization
library(readr) # CSV file I/O, e.g. the read_csv function

# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory

system("ls ../input")

# Any results you write to the current directory are saved as output.

train<-read_csv('../input/train.csv')

test<-read_csv('../input/test.csv')

str(train)
str(test)

dim(which(train$x %in% test$x))
dim(which(train$y %in% test$y))

summary(train$x)
summary(train$y)
summary(test$x)
summary(test$y)


newtrain<-train[order(train$x, train$y),]

newtest<-test[order(test$x,test$y),]


newtrain[1:10,]
newtest[1:10,]



newtrainsmallsquare<-newtrain[which((newtrain$x<1) &(newtrain$y<1)),]
newtestsmallsquare<-newtrain[which((newtest$x<1) &(newtest$y<1)),]

head(newtrainsmallsquare)
head(newtestsmallsquare)

dim(newtrainsmallsquare)
dim(newtestsmallsquare)
