# 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

data=read.csv("../input/train.csv", row.names='row_id', colClasses = c("integer", "numeric","numeric", "integer", "integer", "factor"))
data$day_time<-(data$time)%%1440
data$week_day<-((data$time)%/%1440)%%7
sdata=split(data[, c(1:4,6:7)], data$place_id)
center=t(sapply(sdata, function(x) colMeans(x[c(1:2,5)])))
write.csv(center, file = "center.csv")