UBC-DSCI / introduction-to-datascience

Open Source Textbook for DSCI100: Introduction to Data Science in R
https://datasciencebook.ca/
Other
50 stars 56 forks source link

Change solution for controlling tidymodels output width when fixed upstream #367

Open ttimbers opened 2 years ago

ttimbers commented 2 years ago

We currently use this function to control the tidymodels output width:

print_tidymodels <- function(tidymodels_object) {
  if(!is_latex_output()) {
    tidymodels_object
  } else {
    output <- capture.output(tidymodels_object)

    for (i in seq_along(output)) {
      if (nchar(output[i]) <= 80) {
        cat(output[i], sep = "\n")
      } else {
        cat(str_sub(output[i], start = 1, end = 80), sep = "\n")
        cat(str_sub(output[i], start = 81, end = nchar(output[i])), sep = "\n")
      }
    }
  }
}

When we use it, we should set the code chunk options of the chunk where the object is being generated to results = 'hide', echo = TRUE and then the code chunk option of the chunk that calls that function to echo = FALSE.

For example:

Screen Shot 2021-10-26 at 11 09 34 PM

Although this works, it's not ideal. A better, long-term solution is for this to be fixed in tidymodels... I will open an issue in tidymodels and update our code once they fix this.

trevorcampbell commented 1 year ago

I will open an issue in tidymodels and update our code once they fix this.

@ttimbers where is this issue filed? Would be good to include a link to it here so we can keep track of it. I briefly looked in some of the tidymodels repos but couldn't find it.