I am trying to make some R tutorial presentation using "tutorial" package. There is a link "powered by datacamp" after each code window. I think it is far too much. Is there any way to remove some of "powered by datacamp"? and make it show at the beginning or end of the tutorial?
For example, when you create a R markdown file with tutorial::go_interactive(), it gives "powered by datacamp" after each code window:
---
title_meta: 'R tutorial'
title: Vectors
description: ''
---
```{r, include=FALSE}
tutorial::go_interactive()
knitr::opts_chunk$set(echo = TRUE)
library(knitr)
# no pec
Related
does the button to copy to cliboard exist with R markdown?
It exists in Quarto (with the code-copy option)
and with pkgdown websites
but is it possible to add it to a R markdown or R notebook document?
You could use the package klippy to insert a copy to clipboard button in Rmarkdown HTML documents. To only thing you need to do is add this code somewhere in your document:
```{r klippy, echo=FALSE, include=TRUE}
klippy::klippy()
```
To install the package, you can use the following code:
remotes::install_github("rlesur/klippy")
library(klippy)
Here is a reproducible example:
---
title: "Copy code to clipboard"
date: "2022-10-31"
output: html_document
---
```{r klippy, echo=FALSE, include=TRUE}
klippy::klippy()
```
Some example code:
```{r}
# Summary of mtcars dataset:
summary(mtcars)
```
Output:
As you can see a copy to clipboard button in the top left of the code chunk.
For more information check the documentation.
I wanted to try using knitr::include graphics (link) in my R-markdown document. I am using it as suggested by this link (using the full path):
---
title: "Sample Document"
output:
word_document
---
```{r pressure, echo=FALSE, fig.cap="A caption", out.width = '100%'}
knitr::include_graphics("Z:/../SEM/semflow.png")
```
This is the picture. I tried installing the png package and also tried simply using:
```{r}
knitr::include_graphics("Z:/../SEM/semflow.png")
```
The code is accepted by knitr, which means that it found the file, but it shows up in the Word document like this:
Does anyone have an idea how this could happen?
Related question
A related question (without an answer) can be found here.
Help file: ?knitr::include_graphics
I'm trying to create a presentation in R Notebook with ioslides...when I load libraries at the beginning of my code, they appear in the background of the slides. How can I prevent this from occurring? My slides appear as normal, but in the background is the library name and some additional R Console output...
---
title: 'sample preso'
output: ioslides_presentation
---
```{r libraries}
library(fpp2)
```
We can specify the echo as FALSE
```{r libraries, echo = FALSE}
library(fpp2)
```
I was wondering if there is a way to include the company logo to a PDF document created by R Markdown only on the first page of the document. I have searched for an answer and the closest I could find is this. There are multiple solutions presented in the answers, however, neither of them works for me because they either:
include the logo at every page of the document (not just first); or
include the chapter title in the header (and a horizontal line below it) along with the logo.
I am looking for a way to include just the plain logo, with no chapter titles only on the first page of a PDF R Markdown document and I've ran out of all the resources I could find online. Is there someone who could aid me?
Before anyone asks: yes, it strictly has to be a PDF document, not HTML.
The \includegraphics code line is insert after the R SETUP chunk in markdown.
Here is an example of where I put the line \includegraphics :
---
geometry: "margin=1.5cm"
classoption: landscape
output:
pdf_document: # Export to pdf
number_sections: yes
includes:
in_header: ltx.sty
---
```{r SETUP, include=FALSE, message=FALSE, warning=FALSE}
knitr::opts_chunk$set(echo = FALSE,
warning = FALSE,
message = FALSE,
results = "asis")
library(knitr)
library(kableExtra)
library(some_packages)
options(scipen = 999,
digits = 2,
width = 110)
```
\definecolor{astral}{RGB}{87,146,204}
\allsectionsfont{\color{astral}}
\setcounter{tocdepth}{5}
<!-- Title page -->
\includegraphics[width=7cm]{logo.jpg}
\begin{center}\begin{Large}
Project 1
\end{Large}\end{center}
\vfill
# Some R chunk
```{r results='asis'}
# Table, code, graphics.
```
So the line is insert between the R SETUP chunk and the next R chunk.
I am attempting to use R Markdown Notebooks (.Rmd files) in R Studio to capture notes and excercises while learning R programming. I find that any plots generated through the code chunks are being replicated in the corresponding html file correctly, however I am unable to get images to be replicated in the html.
Sample code below -
The image is a .PNG file in the working directory path.
```{r}
library(knitr)
knitr::include_graphics("MyImage.PNG")
```
This replicates the image in the R Markdown Notebook correctly, but not in the html file.
I am able to replicate the image in the html file by directly using html syntax -
<img src="MyImage.PNG" alt="MyImage">
I have looked through other questions around this topic, but could not resolve this issue through any of the solutions provided. I would be grateful if any of you can help resolve this.
Thanks!
I think this might be a bug to do with adding shiny.
I just did a quick test and it works for a normal document:
---
title: "Test"
output: html_document
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = TRUE)
```
```{r, echo=FALSE, out.width="50%"}
include_graphics("../images/RMarkdownOutputFormats.png")
```
but when I add shiny it doesn't work anymore:
---
title: "Test"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = TRUE)
```
```{r, echo=FALSE, out.width="50%"}
include_graphics("../images/RMarkdownOutputFormats.png")
```
I had the same problem when using shiny_prerendered with a learnr tutorial... This from Yan Holtz worked for me:
library(png)
library(grid)
img <- readPNG("photos/header_stats.png")
grid.raster(img)