Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

export all the content of r script into pdf

Tags:

r

export

pdf

I would want to export all the content of r script into pdf. Could it be possible? I used these commands export, but what I see I just exported graphics

pdf(file = "example.pdf")
  dev.off()

Thank you!

    setwd("C:/Users/Prat/Desktop/c")
    > dir()
    [1] "script.R"
    > knitr::stitch('script.r')
 output file: script.tex

In my folder doesn't appears a script.pdf else a script.tex and a folder with the pictures in pdf enter image description here

like image 613
Oriol Prat Avatar asked Dec 13 '13 20:12

Oriol Prat


1 Answers

You can do this with the knitr package. Here's a workflow:

  1. Save your script as a file (e.g., myscript.r)
  2. Then run knitr::stitch('myscript.r')
  3. The resulting PDF will be saved locally as myscript.pdf. You can use browseURL('myscript.pdf') to view it.
like image 135
Thomas Avatar answered Sep 28 '22 19:09

Thomas