Knitting to Word - Getting errors due to CARET "preProcess()" function

Good day .All is fine when working within Rstudio/RMD . I only get error message when trying to Knit to Word . The Knit process stops when it gets to the "preProcess()" function from Caret. I have checked the syntax and loading of relevant packages to no avail . I'm at a dead-end . Can somebody help?

R Code for Caret :
##Determine the means and sd's and Use the Predict() function to do the adjustments

preProcValues=caret::preProcess(trainSet,method = c("center","scale","YeoJohnson"))



Error Message :
Quitting from lines 864-872 (InsuranceDefault4a.Rmd)
Error in complete.cases(x) : not all arguments have the same length
Calls: ... preProcess.default -> [ -> [.data.frame -> complete.cases

Something to do with this perhaps?

It seems indeed there is an issue with your dataset trainSet that preProcess will try to modify using complete.cases.


When you click on the knit button, your document is rendered in a clean new R session. So nothing from your current workspace is available, everything must be working from your chunks.

You could try restarting your R session in a clean state and try rerunning the chunks in the Rmd, you should find the same error within RStudio/RMD as you said.

Hope it helps.

Many thanks. I will attempt that and feedback later

Hi Cderv , I have redone . Getting same error message .I now note that though its working in normal Rstudio its not working when I code chunk in RMD . Meaning the underlying dataset in trainSet is not the problem . So , what could be the problem?

Is the dataset available and loaded in the previous chunks ? When you run chunk by chunk you need to be sure that data are available.

Currently, we don't have a reprex to reproduce so it so we can't really help further

(FAQ: What's a reproducible example (`reprex`) and how do I do one?)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.