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!
Related
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.
I am trying to build a beamer presentation using rmarkdown. In my presentation I want to include tables using the kable, and kableExtra packages. I am having issues with this because one of the LaTex packages that kableExtra requires is already loaded by the beamer presentation with different options. This is the error message that I receive.
! LaTeX Error: Option clash for package xcolor.
I have been searching for a fix for this but have not had any luck. I have found solutions on the LaTex pages, here and here, but I do not know LaTex and I have not figured out how to apply these solutions in the rmarkdown arena. I have tried looking at the Latex templates in rmarkdown, but I do not understand it well enough to try and implement these solutions.
Any thoughts or solutions would be much appreciated. Here is just a quick sample of the .Rmd that gives the error.
---
title: "Untitled"
author: "Author"
date: "April 28, 2018"
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage[table]{xcolor}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
```
## Slide with R Output
```{r cars, echo = TRUE}
kable(dt, format = "latex")
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
The linked answer on the TeX stackexchange suggests adding table to the class options for the document e.g. \documentclass[a4paper,table]{article}. In order to do this in RMarkdown, you can use a classoption: line in your YAML header:
---
title: "Untitled"
author: "Author"
date: "April 28, 2018"
classoption: table
output:
beamer_presentation:
keep_tex: true
---
Is there any way to pass parameters in an rmarkdown document outside of a code chunk? For example, I'd love to have the ability to have a parameter value be a heading.
Here is a short example .Rmd file:
---
title: "param_test"
author: "test"
date: "September 14, 2017"
output: pdf_document
params:
param_test: this_text
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## I want this heading to be the value of params$param_test
```{r cars}
params$param_test
print(params$param_test)
```
Does anyone have any ideas on this?
You just need to add results='asis' to the chunk then you can print out the header from within the code.
cat("#", params$param_test, "\n")
Another option would be to use the pander library and run
pandoc.header(params$param_test)
I have a R markdown file that I want to output rmarkdown from the script itself. For example, I would have the following simple code in an Rmd file.
---
title: "test"
author: "johndoe"
date: "September 5, 2015"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r cars}
paste("## This is a Heading in Code")
summary(cars)
```
I want "This is a Heading in Code" to render in rmarkdown. There is a solution in an R script to generate markdown as per http://rmarkdown.rstudio.com/r_notebook_format.html. But I am trying to figure out how to do this in a Rmarkdown file. Any help appreciated. Thanks.
Why build the header markup (either in markdown or HTML) manually? Try inline R expressions or some helper functions in pander (to generate markdown programatically):
---
title: "test"
author: "johndoe"
date: "September 5, 2015"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## `r 'This is a Heading in Code'`
```{r title, results='asis'}
library(pander)
pandoc.header("This is a Heading in Code", level = 2)
```
```{r cars, results='asis'}
summary(cars)
```
I searched for a good answer for this for some time after using cat("## Heading") inside results='asis' code chucks. I have seen many people dissatisfied by the results='asis' setting in the code chunk because it sets all results of the code chunk to not be wrapped in a code markup block. We have many cases when we want to output the heading along with results that should be wrapped in markup (e.g. a kable table that renders to a html table).
Here is the solution I found by simply specifying the "asis" attribute to the text object with knitr::asis_output and keeping the code chunk in the default 'markup' setting.
---
title: "test"
author: "johndoe"
date: "September 5, 2015"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r cars}
knitr::asis_output("## This is a Heading in Code")
summary(cars)
knitr::kable(summary(cars))
```
Unfortunately, at the current time knitr::asis_output only works in top-level R expressions, and it will not work when it is called inside another expression, such as a for-loop.
When using the fig.show='animate' option for a code chunk, no other code chunks after are processing. I'm using Windows 8.1 with latest RStudio and R (3.2).
This issue doesn't seem to be a browser related issue. I've tried to output file in multiple browsers and each exhibit the same behavior (see attache image). It seems the HTML code for the second animation (or any after the first) is missing.
Is this a known problem? Can someone verify this is a problem? Or point out what it is that I may be doing wrong?
Thanks
---
title: "Untitled"
author: "TCS"
date: "April 27, 2015"
output: html_document
---
```{r}
x<-runif(100)
```
```{r animation1, echo=FALSE, fig.show='animate', aniopts='controls'}
for (i in 1:20)
plot(1:i, col=i)
```
```{r}
x<-runif(100)
```
```{r animation2, echo=FALSE, fig.show='animate', aniopts='controls'}
for (i in 20:1)
plot(1:i, col=i)
```