# 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
library(dplyr)
library(data.table)
library(googleVis)
library(rpart)
library(rpart.plot)


# 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/clicks_train.csv", nrows = 3000000)
events<-read.csv("../input/events.csv")



#merge data
df <- merge(train, events, by="display_id")


md <- rpart(clicked ~ platform +geo_location +timestamp, data=df, method="class", na.action=na.omit)
rpart.plot(md)

