Jesus Martinez
Jesus Martinez

Reputation: 21

Is it possible to call knitr::spin on two different R scripts and produce a single html file?

I have two different R scripts. I love the idea of knitr::spin. I wanted to know if there's a way to call spin on these two scripts which are both formatted with roxygen2 and produce a single report.

Upvotes: 1

Views: 259

Answers (1)

dmontaner
dmontaner

Reputation: 2165

You can use the text parameter in the spin function. Use readLines to read the files and then cat to write the output:

cat (spin (text = c (readLines ("file_one.r"),
                     readLines ("file_two.r"))),
     file = "output.html")

Upvotes: 4

Related Questions