Printing R Report marcia hon  2018-02-20 11:30
Status: Closed
 
Hello,

I have created an R Report using HTML.

How do I print this report?

Thanks,
Marcia
 
 
marcia hon responded:  2018-02-22 11:28
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
 
marcia hon responded:  2018-02-23 06:54
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.
 
marcia hon responded:  2018-02-23 07:48
I solved my problem.

My R Report was actually HTML.

Therefore, I had to save the Rmd as html and this solved the problem!

Thanks!