Could not execute julia chunks in Rmarkdown - julia

A minimal Rmd file is given below
---
title: "Untitled"
author: "G. A"
date: ""
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(JuliaCall)
```
```{julia}
a = sqrt(2); # the semicolon inhibits printing
println(a)
```
When compiled, I get the following error message:
Julia version 1.5.0 at location C:\Users\g_ari\AppData\Local\JuliaCall\JuliaCall\julia\v1.5.0\bin will be used. Loading setup script for JuliaCall...
Then Rstudio hangs!
I have been trying to resolve this problem.
Thanking in advance for a solution.

Related

`fontawesome` icons ignored when knitting Rmarkdown to PDF

Unfortunately, I fail to knit an *.Rmd file in RStudio to PDF that includes fontawesome-icons. However, when knitting to output: html_document in renders perfectly.
Info:
I am using R version 4.0.3 with RStudio 1.3.1056
I have installed the latest TeX Live distribution
The following example contains elements taken from RStudio's Github:
Icon renders in HTML:
---
title: "FontAwesome in R Markdown"
output: html_document
---
```{r load_packages, message=FALSE, warning=FALSE, include=FALSE}
library(fontawesome)
```
This is an R icon: `r fa("r-project", fill = "steelblue")`.
Icon is ignored for PDF output:
---
title: "FontAwesome in R Markdown"
output: pdf_document
---
```{r load_packages, message=FALSE, warning=FALSE, include=FALSE}
library(fontawesome)
```
This is an R icon: `r fa("r-project", fill = "steelblue")`.
Neither R nor Rmarkdown shows any errors when rendering to PDF. Does anyone have an idea why it does not work?
Thank you very much.
Cheers,
Christian
You can workaround the problem by using the fontawesome5 latex package:
---
title: "FontAwesome in R Markdown"
output:
pdf_document:
keep_tex: true
header-includes:
- \usepackage{fontawesome5}
---
This is an R icon: \faRProject

`knitr::include_url` ignored in output

After updating R to version 3.6.0, and re-installing the required packages, knitting Rmd documents now seems to ignore the knitr::include_url function.
The following is a minimal example, in a file named test.Rmd -
---
title: "test"
author: "Michael Dorman"
date: "May 1, 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
```{r}
knitr::include_url("https://www.wikipedia.org/")
```
```{r}
knitr::include_graphics("https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png")
```
And here is a screenshot of the output, after pressing Knit in Rstudio -
The knitr::include_url function is ignored. No <iframe> element was produced. The knitr::include_graphics function still works, so the image does appear in the output.
Thanks for reading, I appreciate any help!

knitr opts_knit$set(root.dir = "../") ignored when chunk_output_type: console

My actual working directory of a .Rmd file is "C:/Users/Camilo Erasso/Documents". I want to change it using knitr::opts_knit$set(root.dir ="D:/CAMILO") in the setup chunk.
This works fine whit the default YAML option: editor_options: chunk_output_type: inline. But when I change this option to editor_options:
chunk_output_type: console the new working directory is ignored or not changed.
I'm not used to work whit inline result (I prefer the console), for that reason I use this option. The same option can be changed in RStudio>Tools>Global Options...>R Markdown>Show output inline for all R Markdown documents (uncheck) or in the .Rmd setting buttom (next to Knit buttom)> Chunk Output in Console
Toy example:
---
title: "Example root.dir change"
author: "Camilo Erasso"
date: "2 de abril de 2019"
output: html_document
---
```{r setup, include=FALSE}
getwd() #[1] "C:/Users/Camilo Erasso/Documents"
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir ="D:/CAMILO")
```
```{r}
getwd() #[1] "D:/CAMILO"
```
But when using the console output option:
---
title: "Example root.dir change"
author: "Camilo Erasso"
date: "2 de abril de 2019"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
getwd() #[1] "C:/Users/Camilo Erasso/Documents"
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir ="D:/CAMILO")
```
```{r}
getwd() #[1] "C:/Users/Camilo Erasso/Documents" or NOT CHANGED
```
This problem is slightly different from this: https://github.com/yihui/knitr/issues/1575
And related whit this: https://github.com/rstudio/rmarkdown/issues/1077
and this html_notebook ignores global chunk options.
Is this and RStudio issue? Thanks for your help!!!

R Markdown : \#ref() not working

I'm having a lot of trouble getting basic references to work in R Markdown. To reduce complexity from my original project, I've decided to use the bookdown example code, but I'm experiencing the same problem. Here's a link to the intro exmample code: https://github.com/rstudio/bookdown-demo/blob/master/01-intro.Rmd
When I use Knitr to HTML or PDF the file is being generated fine but the references are not working, instead the file will just containt "#ref(example)". Here is an image to show better the output (my emphasis added in red):
Direct link to image: https://i.imgur.com/2yxB5h3.png
Here is a minimal example:
---
title: "Minimal"
output:
pdf_document:
fig_caption: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Here is a reference to the plot below \#ref(fig:minGraph)
```{r minGraph, echo=FALSE, fig.cap="\\label{fig:minGraph}test"}
plot(x=1)
```
With the output appearing as such:
https://i.imgur.com/J3UECqn.png
If you want make use of the bookdown extensions in a normal rmarkdown document you can use bookdown::html_document2 and bookdown::pdf_document2 instead of rmarkdown::html_document and rmarkdown::pdf_document. Example:
---
title: "Minimal"
output:
bookdown::html_document2:
fig_caption: yes
bookdown::pdf_document2:
fig_caption: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Here is a reference to the plot below \#ref(fig:minGraph)
```{r minGraph, echo=FALSE, fig.cap="test"}
plot(x=1)
```
Looks like I was getting my syntax confused by reading the bookdown guide while using just R markdown. Thanks to Ralf for pointing me in the this direction. The correct minimal code would be like so:
---
title: "Minimal"
output:
pdf_document:
fig_caption: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Here is a reference to the plot below \ref{fig:minGraph}
```{r minGraph, echo=FALSE, fig.cap="\\label{fig:minGraph}test"}
plot(x=1)
```

knitr rmarkdown presentation opts_chunk$set error

I am writing a presentation in rmarkdown and compiling to pdf using 'Knit PDF' (Beamer). The code is as following
---
title: "Title"
author: "Author"
date: 'Date'
output:
beamer_presentation:
template: default.beamer
ioslides_presentation: default
themeoptions: compress
widescreen: yes
---
```{r setup, include=FALSE}
opts_chunk$set(cache=TRUE)
```
## Slide 1
A
## Slide 2
B
But I get the following error
Error in eval(expr, envir, enclos): object 'opts_chunk not found Calls: Anno
<nymous> .... Execution halted
I have set the 'Weave Rnw files using' field to 'knitr'. Any ideas on how I might fix this error?
Adding library(knitr) to the code chunk opts_chunk fixed it
{r setup, include=FALSE}
library(knitr)
opts_chunk$set(cache=TRUE)

Resources