# You can write R code here and then click "Run" to run it on our platform

library(readr)
library(randomForest)

# The competition datafiles are in the directory ../input
# Read competition data files:
train <- read.csv("../input/train.csv")
test <- read.csv("../input/test.csv")
train <- train[1:5000,]
train[,1]=as.factor(train[,1])
model <- randomForest(train$label ~.,data= train,importance=TRUE,keep.forest=TRUE)
predicted <- predict(model,test)
head(predicted)
p=as.data.frame(predicted)
ps =data.frame(ImageId = 1:nrow(test),Label = p$predicted)
write.csv(ps, file = "submission-r-rf.csv", row.names=F)



# Generate output files with write_csv(), plot() or ggplot()
# Any files you write to the current directory get shown as outputs
