I am trying:
setwd("directory")
# Load packages
require(knitr)
require(markdown)
# Create .md, .html, and .pdf files
knit("My_Analysis.Rmd")
markdownToHTML('My_Analysis.md', 'My_Analysis.html', options=c("use_xhml"))
system("pandoc -s Sublime.html -o My_Analysis.pdf")
But I get the following error:
javax.script.ScriptException: javax.script.ScriptException: An error occurred when running the script 'script.R', exit code: 1).
Loading required package: knitr
Loading required package: markdown
Error in readLines(if (is.character(input2)) { :
cannot open the connection
Calls: knit -> readLines
In addition: Warning message:
In readLines(if (is.character(input2)) { :
cannot open file 'My_Analysis.Rmd': No such file or directory
Execution halted |
I solved it by doing:
```{r setup, echo=FALSE, cache=TRUE, results='hide', warning=FALSE, comment=FALSE, warning=FALSE, message=FALSE, encoding = 'UTF-8',comments = ""}
knitr::opts_chunk$set(echo=FALSE, cache=TRUE, comment=FALSE, comments = "", warning=FALSE, eval = TRUE, encoding = "native.enc")
#knitr::opts_chunk$get();
knitr::pandoc('script.Rmd', format='latex')
#system("pandoc -s script.docx -o script.pdf")
```
```{r, echo=FALSE, cache=TRUE, results='hide', warning=FALSE, comment=FALSE, warning=FALSE, message=FALSE, encoding = 'UTF-8',comments = ""}
currentdir <- getwd()
assign("pdf_filename", paste(currentdir, "/script.pdf", sep=""))
file.copy(from = pdf_filename,
to = "/newdirectory/script.pdf")
system("rm script.* *.tsv")
```
However, my pdf report looks like the attached.
It is supposed to have a logo, and the html/code should be something legible. |