4

I am trying to write a vignette based on some example data included with my package. I want the vignette to be as robust as possible to minor changes in example dataset -- for example an id changing.

What I was hoping to do is to define the ids in a hidden code chunk:

<<echo=FALSE, results=hide>>=
ex_id <- functionToGetID() ## Let's assume it returns 1.
@

Then use that variable to insert into functions later in the document. Something like:

<<>>=
someFunction(id = get("ex_id"))
@

The goal is for the text in the vignette to show:

someFunction(id = 1)  ## and NOT someFunction(id = get("ex_id"))

I am not sure how to inject a variable into the code chunk, such that the LaTeX result only shows the value of the variable, and not how the variable was called.

Ho1
  • 1,239
  • 1
  • 11
  • 29
dayne
  • 7,504
  • 6
  • 38
  • 56

0 Answers0