Regarding to your comments I think you have to use the extra-file to put there the results of the decisions tree. A short commented way is given below.
dTest <- read.csv("test.csv") #Read in the datasets
dTrain <- read.csv("train.csv")
dSub <- read.csv("sub.csv")
dTrain$y <- as.logical(dTrain$y) #Change type of y to logical
library(rpart)
dtree <- rpart(y ~ . - id, data=dTrain) #Make decission tree
all(dSub$id == dTest$id) #Test of order of dSub$id is equal to dTest$id
#[1] TRUE
dSub$y <- predict(dtree, newdata=dTest) #make prediction
head(dSub)
# id y
#1 38062 0.05454481
#2 40079 0.05454481
#3 39238 0.21288164
#4 36069 0.05454481
#5 40531 0.05454481
#6 38164 0.21288164