4

I'd like to generate html file via script below which is a part of complex source code but I don't want to install RStudio on users machine.

I'm using pandoc available at: pandoc from github and the reference for path to this pandoc file is used in Sys.setenv: "C:/Users/username/AppData/Local/Pandoc".

If I use RSTUDIO_PANDOC in Sys.setenv command, everything works fine in my script below but I'm just confused if RSTUDIO_PANDOC in Sys.setenv command uses default RStudio pandoc file which I don't wanna use. Is there any replacement by RSTUDIO_PANDOC to be sure I don't need RStudio to be installed on user's machine and I can refer only to pandoc file what I downloaded from the link above.

Sys.setenv(RSTUDIO_PANDOC="C:/Users/username/AppData/Local/Pandoc") setwd("C:/Users/username/interactiveKnitr") # set path to .Rmd file knit('knit.Rmd') # creates md file render('knit.Rmd') # creates html file 

Thank you very much for any of your explanation and help on this. I'm very new in this area.

2
  • Have you tried knitr::pandoc? Commented Mar 11, 2016 at 8:25
  • Yes, I've tried that. That generates html but without plot_ly stuffs and in incorrect format. That's the reason why I'm using knit and render to .Rmd file. Commented Mar 11, 2016 at 8:36

1 Answer 1

2

You can use the package pander form within R. Despite of that I usually prefer to install pandoc myself and to use a system call if I need to run everything form R.

knit (input = "file.Rmd", output = "file.md") system ("pandoc file.md") 

Then is easier to tune pandoc parameters and you make sure to run the version you have installed. It makes also things easier if you want to create tex or pdf version of the document.

Sign up to request clarification or add additional context in comments.

4 Comments

And do you still need to use Sys.setenv(RSTUDIO_PANDOC="C:/Users/username/AppData/Local/Pandoc")?
I do not think so. Indeed I use it outside Rstudio (also form R studio). The call to knitr depends just on knitr parameters and the call to system should not be affected by Rstudio parameters... but I guess you can make sure of the pandoc version you are using setting the full path in your system call system ("C:/User..../pandoc file.md")
I have no idea how can I test this, because I don't want to uninstall RStudio from my pc :-)
Run R outside Rstudio. If you are in Windows you can use the standard R interface or use the batch mode form the DOS shell. See here statmethods.net/interface/batch.html. Writhe your file.Rmd with any editor (Rstudio for instance) save it just as it is (a text file) and then close Rstudio and open R without it. Remember to load the knitr package.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.