Could not find function "train"

Just first off, ideally, pose your questions with a reproducible example in future (FAQ: What's a reproducible example (`reprex`) and how do I create one?). That makes it much easier to understand the issue and help resolve.

You need to load a package (with the library(PACKNAME) command) before you have access to the data and function contain within. Looks like you're using caret package's train, so you'd want to run,

myModel <- train(...)
1 Like