Error while using predict After splitting into test and train the glm function is used on train set. For example 

m1 = glm(target ~ ., data = train, family="binomial")


Then

P = predict(m1,newdata=test, type="response")


Here I am getting warning message : 


  newdata has 60000 rows but variables found have 100000 rows


And the next step: 

table(test$target, P&gt;0.5)


Here I am getting error: 


  all arguments must have same length


What is the solution for this?
Works find for me. Maybe you have some error in the definition of the train/test set? 

library(ISLR)
library(glmnet)
# Load data
iris = iris[iris$Species=="Setosa" | iris$Species=="versicolor",]
iris$Species = as.factor(iris$Species)
# Make a test/train split
set.seed(123)
smp_size &lt;- floor(0.75 * nrow(iris))
train_ind &lt;- sample(seq_len(nrow(iris)), size = smp_size)
train &lt;- iris[train_ind, ]
test &lt;- iris[-train_ind, ]

m1 = glm(Species ~ ., data = train, family="binomial")
p = predict(m1,newdata=test, type="response")
table(test$Species, p&gt;0.5)