# 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.
testset <- read.csv("../input/test.csv")
dataset <- read.csv("../input/train.csv")

print("dataset loaded")

dataset$hour <- round((dataset$time %% 86400) / 3600)

print("Hours Converted loaded")
hour0 <- dataset[dataset[,"hour"] == 0 && dataset[,"hour"] == 1, c("x", "y", "place_id")]
#summary(hour0)
hour1 <- dataset[dataset[,"hour"] == 2 && dataset[,"hour"] == 3, c("x", "y", "place_id")]
hour2 <- dataset[dataset[,"hour"] == 4 && dataset[,"hour"] == 5, c("x", "y", "place_id")]
hour3 <- dataset[dataset[,"hour"] == 6 && dataset[,"hour"] == 7, c("x", "y", "place_id")]
hour4 <- dataset[dataset[,"hour"] == 8 && dataset[,"hour"] == 9, c("x", "y", "place_id")]
hour5 <- dataset[dataset[,"hour"] == 10 && dataset[,"hour"] == 11, c("x", "y", "place_id")]
hour6 <- dataset[dataset[,"hour"] == 12 && dataset[,"hour"] == 13, c("x", "y", "place_id")]
hour7 <- dataset[dataset[,"hour"] == 14 && dataset[,"hour"] == 15, c("x", "y", "place_id")]
hour8 <- dataset[dataset[,"hour"] == 17 && dataset[,"hour"] == 16, c("x", "y", "place_id")]
hour9 <- dataset[dataset[,"hour"] == 18 && dataset[,"hour"] == 19, c("x", "y", "place_id")]
hour10 <- dataset[dataset[,"hour"] == 20 && dataset[,"hour"] == 21, c("x", "y", "place_id")]
hour11 <- dataset[dataset[,"hour"] == 22 && dataset[,"hour"] == 23, c("x", "y", "place_id")]
hour12 <- dataset[dataset[,"hour"] == 24, c("x", "y", "place_id")]

print("plotting 1")
ggplot(hour0,aes(x=x,y=y,color=as.factor(place_id),shape= as.factor(place_id))) +
    geom_point(size=4) 

print("plotting 2")    
ggplot(hour1,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
    geom_point(size=4) 
    
ggplot(hour2,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
    geom_point(size=4) 

#ggplot(hour3,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 
    
#ggplot(hour4,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 
    
#ggplot(hour5,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 
    
#ggplot(hour6,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 
    
#ggplot(hour7,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 

#ggplot(hour8,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 
    
#ggplot(hour9,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
#    geom_point(size=4) 
    
ggplot(hour10,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
    geom_point(size=4) 
    
ggplot(hour11,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
    geom_point(size=4) 
    
ggplot(hour12,aes(x=x,y=y,color=as.factor(place_id),shape=as.factor(place_id))) +
    geom_point(size=4) 
    