title: RMarkdown error when trying to knit with "gains" function
body: <p>I keep getting the error below when trying to knit my document. Trying to make a lift chart. It works in RStudio but when trying to knit there is an error. I have gains as the (actual_data, predicted, groups = length(predicted)). What seems to be the issue? Is there any way to resolve this? Able to provide any information needed.</p>
  <pre><code>    Error in as.data.frame.default(x) : 
        cannot coerce class '&quot;gains&quot;' to a data.frame
  </code></pre>
  <p>Thank you!</p>
  <pre><code>--- output: word_document
  knitr::opts_chunk$set(echo = TRUE)
  R Markdown
  library(readr)
  Mod_4_banks &lt;- read_csv(&quot;see attached image&quot;)
  
  dim(Mod_4_banks)
  head(Mod_4_banks, 20)
  sapply(Mod_4_banks, mean)
  colnames(Mod_4_banks)
  sapply(Mod_4_banks, levels)
  sum(is.na(Mod_4_banks))
  Mod_4_banks &lt;- Mod_4_banks[,-1]
  Bank_log_reg &lt;- glm(`Financial Condition` ~., data = Mod_4_banks, family = &quot;binomial&quot; )
  options(scipen=999)
  summary(Bank_log_reg)
  library(gains)
  library(caret)
  pred_mod &lt;- predict(Bank_log_reg, Mod_4_banks, type = &quot;response&quot;)
  sample_row &lt;- sample(c(1:20), size = 5)
  data.frame(actual = Mod_4_banks$`Financial Condition`[sample_row], predicted = pred_mod[sample_row])
  gain.df &lt;- gains(Mod_4_banks$`Financial Condition`, pred_mod, groups = length(pred_mod))
  
  View(gain.df)
  
  plot(c(0,gain.df$cume.pct.of.total*sum(Mod_4_banks$`Financial Condition`))~c(0,gain.df$cume.obs), xlab = &quot;Number of Cases&quot;, ylab = &quot;Cummulative&quot;, main = &quot;Lift Chart of Financial Condition&quot;, type=&quot;l&quot;)
  
  lines(c(0,sum(Mod_4_banks$`Financial Condition`))~c(0,dim(Mod_4_banks)[1]), lty=2)
  ```
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xCsDM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xCsDM.jpg" alt="Short amount of data used for this project" /></a></p>