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?
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.