# 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)

# 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")
train <- read_csv("../input/train.csv") #,n_max=10000)
glimpse(train)
cat("Semana ",unique(train$Semana ))
print("train")

test <- read_csv("../input/test.csv")#,n_max=10000)
glimpse(test)
cat("Semana ",unique(test$Semana ))
print("test")


cliente_tabla <- read_csv("../input/cliente_tabla.csv")
glimpse(cliente_tabla)
cat("unique clinte ID   ",length(unique(cliente_tabla$Cliente_ID)),"out of : ", nrow(cliente_tabla))
print("cliente_tabla")
sample_submission <- read_csv("../input/sample_submission.csv",n_max=10000)
glimpse(sample_submission)


producto_tabla <- read_csv("../input/producto_tabla.csv",n_max=10000)
glimpse(producto_tabla)


town_state <- read_csv("../input/town_state.csv",n_max=10000)
glimpse(town_state)

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

count<-table(town_state$State)
barplot(count, main="state", ylab="Count of Agencies",las=2,space=1)
count<-table(town_state$Town)
barplot(count, main="Town", ylab="Count of Agencies",las=1,horiz=T, cex.names=0.4,ylim=c(1,2000),space=20)
