subsetting in Logistic Regression in R

I received the following error messages when splitting and subsetting my data in the process of logistic regression in R:

Error: Must subset rows with a valid subscript vector.
i Logical subscripts must match the size of the indexed input.
x Input has size 333030 but subscript i has size 9.
Run rlang::last_error() to see where the error occurred.