Creating TeX file from RMarkdown without LaTeX installed on PC - r

This maybe a duplicate but couldn't find the question here.
For some reason I cannot have LaTeX installed on my PC. I am hoping to run my .Rmd code and generating .tex file (using keeptex true in YAML) which I can use on another PC to generate pdf.
I haven't tried this yet but would this work?

Have you tried installing/using the tinytex package?
install.packages(tinytex)
tinytex::install_tinytex()
https://yihui.org/tinytex/
This will allow you to create PDFs from LaTeX without having a full LaTeX installation

Related

writing .Rmd files in Geany IDE

I've been using Geany under Linux to write R scripts for years. Now I want to use R Notebook and R Markdown.
So, what should I do to make Geany recognize .Rmd files used by R? Is it possible?
I did not find a proper plugin or documentation for .Rmd files in Geany.
Thanks

tinytex not finding tabu.sty when downloading PDF for the first time

I am generating a PDF r markdown document as part of a downloadable report in a shiny application using download handler. I am using the tinytex package.
Once published to RStudio Connect though if I try and download I am getting an error that states that tabu.sty cannot be found and it errors. If though I then download again straight after the PDF is published and downloaded without any issues. Any thoughts as to why this may be happening? The same thing occurs in rstudio but with a different sty file (multirow.sty). I use neither tabu or multirow in my markdown documents.

Shiny app executable with latex and pandoc

I'm currently developing a shiny app that I want to install in different computers that currently doesn't have R, LaTex and pandoc install. I found this blog https://www.r-bloggers.com/deploying-desktop-apps-with-r/ where it is explain how to do this. I followed all their instructions and it work great until I generate some pdf that I wrote with knitr. The error I get is:
Warning: Error in htmlwidgets::saveWidget: Saving a widget with selfcontained = TRUE requires pandoc. For details see:
https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md
which I interpret as you don't have Pandoc, and I will probably get the same for LaTex if the code gets there.
I know I have to install portable MikTex and portable pandoc in the same folder I have the shiny app and the portable R and Chrome, so I downloaded from here https://miktex.org/portable and here https://github.com/pandoc-extras/pandoc-portable and install theme. But this did not work
Reading the R blogger and the other webpage cited there I know I have to change somewhere in the code, maybe the .bat or in R or in some file of MikTex and pandoc, the direction that R is going to use but I just have no idea how to do this.
The .bat file currently has:
SET ROPTS=--no-save --no-environ --no-init-file --no-restore --no-Rconsole
R-Portable\App\R-Portable\bin\Rscript.exe %ROPTS% runShinyApp.R 1> ShinyApp.log 2>&1
Thanks in advance

Can't open connection when shortcut-knitting in RStudio

I have a CSV file I made shared publicly via Google Drive. I used bit.ly to generate a nice short URL, and I can read it into R just fine via
read.csv("http://bit.ly/1pRClOk")
(It's a pretty small dataframe, 9x17, so don't be worried about trying it out.)
I put my code in in a .Rmd document, and I can knit it just fine from the console if I run knit("csvtest.Rmd"), but if I knit using the Knit HTML button in RStudio (Ctrl-Shift-K), I get
Error in file(file, "rt"): Cannot open the connection.
In general, I much prefer to knit using the shortcut, because doing so seems to knit in it's own R session which means I can be sure I'm not accidentally referencing something in my global environment. I'd also like to distribute the .Rmd file without having to explain to people that they need to explicitly knit from the console.
Is there a way I can make make the connection work when using the knit shortcuts?
I'm on Windows 7 and using current versions of RStudio (0.98.1091) and knitr (1.8).
MWE
Using this document saved as csvtest.Rmd. I can run the code in RStudio line by line, no problem, typing knit2html("csvtest.Rmd") produces an HTML document with the data. Knitting via shortcut produces the error above.
---
title: "Can knitr open connections?"
output: html_document
---
```{r}
reentry = read.csv("http://bit.ly/1pRClOk")
head(reentry)
```
If you only care about a solution under Windows, I believe you need to setInternet2(TRUE) in te Rmd file before you read the file, since it is essentially an HTTPS link, which you cannot read into R by default.
A more portable solution is to use the downloader package to download the file (you can download it to a tempfile()) before reading it.

Is there a way to knitr and produce .rmd files using the external tools function of the StatET Eclipse plugin?

I'm becoming a fan of reproducible analyses and of Sweave, Beamer and specially of the knitr package.
RStudio allows to Sweave and knit documents with just one click, but although RStudio is easy to install, it is quite unstable and does not have the maturity and flexibility of the StatET plugin from Eclipse. Most tutorials or listservs tend to refer back to the RStudio IDE when asking questions about knitr and RMarkdown, but there's little out there about how to install and turn Markdown files into .Rmd using the knitr package. Jeffrey Horner said when he announced the R markdown package that:
"Markdown documents to HTML, created in collaboration with RStudio. It offers the complete R Markdown feature set available in their best-of-breed IDE, however useRs can integrate markdown into their own toolchain of choice."
The last sentence is what I have not been able to figure out. Elsewhere, I've seen suggested to manually knitr by using library(knitr); knit('myfile.Rmd'), however, when attempting to do this, I receive an error:
Warning in file(con, "r") :
cannot open file 'My file.Rmd': No such file or directory
Error in file(con, "r") : cannot open the connection
I was able to turn the My file.md file into html using:
library(markdown)
markdownToHTML(file = "C:/Dropbox/eclipse/8. CM/Myfile", output="C:/Dropbox/eclipse/8. CM/Myfile.html")
However, the R code is not run, and I suspect that I need to knit the .Rmd file first. Any help or directions about how to be able to knitr markdown files in StatET or somewhere else than Rstudio would be much appreciated.
I'm using R version 2.15.1 (2012-06-22) on a Windows 7 Professional OS.
Eclipse Version: 3.8.0 and StatET 3.0.
One way to do it is to use an R snippet:
1) create a stateET R project, with this file https://raw.github.com/yihui/knitr-examples/master/001-minimal.Rmd in it.
2) in Windows-> Preferences -> StatET -> Run/Debug -> R Code Snippets
click "Add...". to create a new snipped called Rmd2html.
content of the snippet:
file <- "${selected_resource_loc}"
if (!nzchar) stop('Select a file first')
library(knitr)
library(markdown)
library(tools)
md_file <- knit(file)
html_file <- paste(file_path_sans_ext(md_file), '.html', sep = '')
markdownToHTML(md_file, html_file)
click "OK", "OK".
3) back in your project, in the Project Explorer view, right click on the minimal.Rmd file,
and select "Run Code Snippet in R -> Rmd2html"
This should generate the minimal.html file.

Resources