Converting Knitr to PDF - r

I am trying to convert my knitr to a PDF.
Currently I have been trying the drop down menu in RStudio and selected Knit to PDF.
Error: pandoc version 1.12.3 or higher is required and was not found.
I have downloaded Pandoc here (pandoc-1.15.0.6-windows.msi):
https://github.com/jgm/pandoc/releases
I tried re-running it and the same problem keeps occurring. I am not sure if it is a directory issue or if I am just typing something wrong in but I am having major trouble with this.
Would someone be able to produce a reproducible example in how to type this into R.
Any help would be greatly appreciated and would save me big time. (By the way, I have no trouble with HTML, just PDF)
Thanks!

Related

! LaTeX Error: File `knitr.sty' not found

I am trying to knit a simple markdown file to a pdf using knitr and R Studio. The chunks all run fine and I have no problems knitting to an HTML document, but get the following error when trying to knit to a pdf:
! LaTeX Error: File `knitr.sty' not found.
I have reinstalled tinytex and made sure that the knitr and rmarkdown packages are up to date. I've looked around and while there are similar issue with other *.sty files, I can't find anything relating to this one.
Thanks in advance for any advice
Solved this: for some reason I had listed several R packages in the 'extra_dependencies' part of the YAML metadata. Once removed it worked.

R Markdown - First Attempt - Strange Error Message

I'm trying to create an R Markdown script for the first time today in RStudio. I have an existing R script which produces lots of graphs, and I'm hoping to use Markdown to produce .pdf files containing these graphs.
I started very simple:
```{r}
10 * 10
```
When I clicked on the "knit" button I saw an error message:
I ran getOption("repos") at the console and I saw:
"https://mran.microsoft.com/snapshot/2019-02-01"
I don't know if it's relevant (I suspect it is): I'm not using standard R, I'm using Microsoft R Client 3.5.2 because I need access to the revoScaleR package.
I don't really understand what's going on here but it looks as if I'm using out of date stuff...can anyone help fix this please?
Thank you.
Ahhhh...I think I've fixed it:
options(repos = c(CRAN = "https://cran.rstudio.com"))
Hoping this doesn't have any unintended consequences! >crosses fingers<

R Studio Convert .RMD to pdf

all
Ufff... I believe I did my hw to research this and still don't have an answer so asking all:
I have R-Studio, valid RMD file, when I tried to I don't get new .pdf file, I have viewer which is still html.
No problem to create HTML, it works fine, but I need pdf.
tried to use render ("file.RMD", "file.PDF") to find that I don't have render, tried install pandoc, got an error < package ‘pandoc’ is not available (for R version 3.1.2)>
so what is the simple way to get that pdf, why my doesn't work as desinged? what I'm missing I put that info into header too...
output: pdf_document
Im totaly lost, appreciate help.
render("Proj1.RMD", "Proj1.pdf")
Best
Mario

gvisMotionChart is not working in R markdown file

I need to embed gvisMotionChart into an R markdown file and find an example interactive which is really helpful. However when it comes to the googlevis plotting I keep getting this error when I press the "run code" button:
connection to openCPU failed:
error
undefined
NetworkError: A network error occurred
Can anybody figure out the solutions?
Thanks in advance.
The googleVis package creates the javascript that has to be embedded into an HTML document in order for the interactive plot to run on a webpage. You won't be able to get it to work in the console or in Rstudio for that reason. The only way to know for sure if it's working is to knit it to HTML, and then publish it to Rpubs (or anywhere else online). Once it is online it will work. Depending on your browser settings, you might be able to get it to work by opening the HTML locally, but the browser often blocks the embedded plot when opened locally.
Without seeing your actual code, I can't provide you with anything more specific than that.
EDIT: I thought I would add that several months ago I made a markdown file detailing interactive plots in R for a class. You can find it here: http://rpubs.com/crmhaske/uwloo670_Interactive_Plots
If you scroll down to the very end you'll see the example I did using gvisMotionChart. You have to make sure the place where you print the graph is in it's own chunk, and that results is asis:
```{r results='asis'}
print(p,'chart')
```

How do I generate reports in R without texi2dvi or TeX installed?

I've been struggling for a week now trying to figure out how to generate reports in R using either Sweave or Brew. I should say right at the beginning that I have never used Tex before but I understand the logic of it.
I have read this document several times. However, I cannot even get a simple example to parse. Brew successfully converts a simple markup file (just a title and some text) to a .tex file (no error). But it never ever converts tex to a pdf.
> library(tools)
> library(brew)
> brew("population.brew", "population.tex")
> texi2dvi("population.tex", pdf = TRUE)
The last step always fails with:
Error in texi2dvi("population.tex", pdf = TRUE) :
Running 'texi2dvi' on 'population.tex' failed.
What am I doing wrong?
The report I am trying to build is fairly simple. I have 157 different analysis to summarize. Each one has 4 plots, 1 table and a summary. I just want
output plot 1,2,3,4
output table
\pagebreak
...
that's it. Can anyone help me get further? I use osx, don't have Tex installed.
thanks
You cannot run this without texi2dvi or TeX installed.
An alternative may be html output -- the hwriter package is useful for that.
That said, if you want to produce pdf out, Sweave is the way to go. Frank Harrell's site has a lot of useful info but all this requires a bit of familiarity with LaTeX so you may need to install and learn that first.
If you are on OSX, might as well install the full tex live
http://mirror.ctan.org/systems/mac/mactex/MacTeX.mpkg.zip
It is a big download, but it will be nice to never have to install additional packages.
Another solution: the ascii package in conjonction to your favorite markup language (asciidoc, txt2tags, restructuredtext, org or textile).
http://eusebe.github.com/ascii/
It may be worthwhile spending a week or so just using LaTeX without R and going through a bunch of introductory LaTeX tutorials.
Thus, when you start producing Sweave or Brew documents and you get errors, you will be better able to identify whether the error is arising from LaTeX or Sweave / Brew.
A couple of Windows tools that make it easy to get started with LaTeX include MikTeX + TeXnicCenter or MikTeX + WinEdt.
Another solution is to try a solution of connecting R to microsoft.
It is much weaker then Sweave, but for basic reporting might be what you need.
You might want to go through the example sessions given here: Exporting R output to MS-Word with R2wd (an example session)
I've also been hearing a lot of good things about the knitr package. It seems to resemble Sweave a lot, but add some more to it. I would definitely take a look at it.

Resources