My suggestion for you was to start with applying the guidelines to reproduce their example. If you can't with their data, it probably won't be possible with your own. When we encourage reproducible example, called a reprex, it's for the purpose of *illustrating* the problem and the specific points in the code that may be roadblocks.

Let's go back to the guidelines. *I* got different results than they did. One was close and the other was way off. If this were my own work, I'd go looking after a better example that I could reproduce. Once I did, I'd check my understanding of how the roles of the dependent and independent variables in my data relate to the example.

In your work, I strongly encourage you to review the basics of logistic regression (which your code doesn't do) for independent variables that can take on more than two values. This is covered in Chapter 5 of Hosmer, David W., Stanley Lemeshow, and Rodney X. Sturdivant. *Applied logistic regression* . Hoboken, New Jersey: Wiley, 2013, the standard text on logistic regression.

The analysis that your code is set up to do is a predictive type of machine learning that is well described in @rafalab's free R course textbook in Section 33.7.