I would like to include external markdown file; however, I could not handle it on RStudio so far. If I manually copy/paste the content of about.md into main.R, there is no issue. I mean setting up everything related with flexdashboard is fine. On the other hand, I have tried to reinstall rmarkdown package and import it by library("rmarkdown"). This is not fair enough because flexdashboard has already its internal one. So it should not be related with whether the rmarkdown installed or not apart from flexdashboard installation. Any suggestions ?
Thanks
I have prepared minimal code with its output as below:
'about.md'
test1
=======================================================================
**testttt**
testttt
**testttt2**
testttt
main.R
---
title: "test"
author: "test"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
```
```{r}
includeMarkdown('about.md')
```
The output:
Quitting from lines 17-18 (minimal.Rmd)
Error in includeMarkdown("about.md") :
could not find function "includeMarkdown"
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
The function includemarkdown is from the package htmltools. So you have to load the library or use:
```{r}
htmltools::includeMarkdown('about.md')
```
Related
I´m new at R. I was trying to knit a Rmd file in RStudio into a pdf, but it presents the following error:
Quitting from lines 17-20 (projeto_final_20220429.Rmd)
Error in .External2(C_dataviewer, x, title) : unable to start data viewer
Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> View
Execution halted
The code written in those lines was this:
library(readr)
despesas_municipios_saude_educacao <- read_csv("despesas_municipios_saude_educacao.csv")
View (despesas_municipios_saude_educacao)
Is there anyone who can help me?
On MacOS, knitr attempts to load the X11 library in order to view the data frame, which fails because knitr isn't designed to interact with an end user. Regardless of the underlying operating system, since utils::View() is meant to work in a windowing environment (e.g. RStudio, RGui, R Tools for Visual Studio, etc.), it can't be used to print a data frame in an R Markdown document.
---
title: "Error with View()"
output: html_document
date: "`r Sys.Date()`"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## A header
Here is a reproducible version of the stackoverflow question [Execution Halted when Knitting](https://stackoverflow.com/questions/72068679/execution-halted-when-knitting-in-rstudio).
```{r mtcars}
data(mtcars)
View(mtcars)
```
...generates the following error:
To display a subset of data in a markdown file, one can use head() instead of View().
---
title: "Error with View()"
output: html_document
date: "`r Sys.Date()`"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## A header
Here is a reproducible version of the stackoverflow question [Execution Halted when Knitting](https://stackoverflow.com/questions/72068679/execution-halted-when-knitting-in-rstudio).
```{r mtcars}
data(mtcars)
head(mtcars)
```
...and the output in HTML:
We can improve the look of the output by turning off echo on the R chunk used to print the table, and use knitr:kable() to format the data frame.
We use the following R Markdown code, including the "pipe" argument to appropriately space the columns in the output.
We can make the output look nicer with `knitr::kable()`.
```{r kableVersion,echo=FALSE}
library(kableExtra)
kable(head(mtcars),"pipe")
```
...and the output renders like this in HTML:
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
I am trying to run a Julia chunk in RMarkdown. I am using the package JuliaCall. Here are the steps I've completed:
Downloaded Julia
Installed JuliaCall
Run the code julia_setup(JULIA_HOME = "C:/Users/James/Documents/Julia 1.5.1/bin")
Run julia <- julia_setup()
Here is a minimal example of my RMarkdown file:
---
title: "julia_eg"
author: "James"
date: "9/23/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
this is a julia example
```{julia}
a = sqrt(17)
a
```
When I try and knit this, it tells me it cannot find Julia - I get this error:
Error in julia_locate(JULIA_HOME) : Can not find the Julia installation in the default installation path 'C:\Users\James\AppData\Local' Calls: <Anonymous> ... withVisible -> eval -> julia_setup -> julia_locate
So clearly my running of julia_setup in step 3 above didn't have the desired effect - even though it did run this for sometime and told me that it had completed that task.
Is there a more straightforward way of getting it to find Julia?
Rmarkdown is only aware of any code that is run in the immediate session, to avoid creating documents that will be impossible to compile by itself.
As such you'll have to add the code to the initial code chunk
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
Julia_setup(JULIA_HOME = "C:/Users/James/Documents/Julia 1.5.1/bin")
julia <- julia_setup()
```
Im tying to use a function to generate plotly charts within flexdashboard.
---
title: "Single Column (Fill)"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(plotly)
```
### Chart 1
```{r}
pltFunction(x,y)
```
If i click the green arrow, which says "run current chunk", the function works and plots the graph underneath the code chunk.
However, if i click knit, i get:
Error in pltFunction(x,y) : could not find function "pltFunction"
Calls: ... handle -> withCallingHandlers -> withVisible ->
eval -> eval
I'm very new to shiny et al, apologies for the simple question here, but can flexdashboard see the global environment? The function and all the data it needs are there.
Thank you!
Following on from this question... I am not sure where to set knitr option if I want to output a separate file of R code. The following does not provide the expected additional .R files in my working directory.
---
output: ioslides_presentation
---
```{r setup, include=FALSE}
library("knitr"); purl("myfile.rmd")
#library("knitr"); knit("test_tangle.Rmd", tangle = TRUE)
#opts_knit$set(tangle=TRUE)
```
## Slide with Plot
```{r, echo=TRUE}
plot(cars)
```
but an error message...
Quitting from lines 6-7 (myfile.rmd)
Error in readLines(if (is.character(input2)) { :
cannot open the connection
Calls: <Anonymous> ... withVisible -> eval -> eval -> purl -> knit -> readLines
Execution halted
I recommend you to use the hook_purl function instead. The function purl() (or equivalently, knit(tangle = TRUE)) may fail to work in certain cases, and the hook function hook_purl() is more reliable. See ?hook_purl for more information.
---
output: ioslides_presentation
---
```{r setup, include=FALSE}
library("knitr")
knit_hooks$set(purl = hook_purl)
```
## Slide with Plot
```{r, echo=TRUE}
plot(cars)
```
Then as you knit the document, the R script will be automatically generated.