0

I am trying to use the function rebus.pls in the plspm library. This function generates a dendrogram and then prompts for user input (number of desired classes) before proceeding. (Sorry, I cannot provide a code sample as using this function requires a large amount of data.)

I want to produce a static report of my analysis process using knitr. I would be satisfied with either supplying the input during knitting (tedious but produces the desired output), or specifying the input within the Rmd document (preferred solution).

The function rebus.pls is not documented as accepting an optional argument to supply the number of classes. Nor does the documentation give me the name of a global variable I can set in advance. Therefore I believe I'm limited to either supplying the input during knitting, or simulating that by telling knitr in advance "when prompted for user input, use this response." I was unable to find instructions for doing either of those two things; I only found descriptions of how to create interactive HTML output with Shiny.

I am currently generating the reports by using 'knit' in RStudio but could use a *nix command-line solution, e.g.

echo "3" | Rscript -e "library(knitr); knit('Report.Rmd')"

Is this the best I can do or are there other solutions for my problem of "How can I use knitr when using a function which requires user input, when the desired output is a static PDF report using hardcoded input?" I'd prefer something a little more self-documentating.

Ann
  • 1
  • 2
  • Here is the code for that function https://github.com/gastonstat/plspm/blob/master/R/rebus.pls.r – Dason Mar 17 '18 at 12:45
  • Okay, so I could fork the code and use my own version of the function where the variable is hardcoded, or else make a pull request supplying an optional argument, that's definitely a solution. But is there a generic way to solve this problem, if I run across it again, with a different library? I'm pretty new to R so I'd like to understand the best way to solve this. – Ann Mar 17 '18 at 12:54

0 Answers0