Problems knitting a R Markdown document into R Shiny App

Hi all,

Hopefully a quite straight forward question here.
I am using the flex dashboard template and I insert a ggplot graph from my environment.
I run the chunk and the graph displays clearly.

Problem is, I want to bring this graph to a Shiny Environment. So, I save, then render. The file will not render correctly and I get this answer "Line 19 Error in eval(expr, envir, enclos): object 'finished' not found calls: ...handle -> withCallingHandlers -> with visible -> eval ->eval Execution halted"

and the code is listed below:

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
Finished
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}

```

### Chart C

```{r}

```

Thanks legends.

This is pretty clear - finished object is not found when you Knit the document.

In your example code there is

So Finished variable is looked for in the environment, and it does not exist. If the object in your workspace, do remember then when you knit a document, it will be run in a clean background R process - so new worspace.

It is best that a Rmd document contains all the steps and computation to be ran on its own.

To solve this, you need to make the variable available in the document.

  • Create the object in another chunk inside the document
  • Save the object to disk and load the saved object when rendering the document
  • Anything else that allows for the Rmd file to know about the finished object you need at rendering.

Hope it helps

Thanks cderv - I'm new to this language.

I want to clarify some things if you would be so kind:

  1. I narrow down my original data table and reach the point of having my final object (2 observation, 3 variable data table). I complete this narrowing down process within a chunk in the r markdown document.
    So, I don't quite understand why when I try to knit, I get; Object "False_Data" not found.

Object "False_Data being my originally imported data table that I brought in from excel.

  1. When you say save the object to disk, will i reach the same effect by entering save.image("everything.Rdata?"). If not, how do I save to disk?

Here is my coding: ("Final" being the narrowed down data table)

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(gdata)
library(dplyr)
library(magrittr)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}

```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}

```

### Chart C

```{r}

near <- False_Data %>% 
select(-OPPONENT,-OUTCOME)
Final <- near%>%filter(TEAM=="Bulls")
Final
save.image("everything.Rdata")
load(Final)
```

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Hi

Sorry for the long delay.

I don't see where you are loading False_Data in your example document. Be sure it is in a chunk that is evaluated (eval = TRUE which should be the default)
If you create this object in a chunk in the same document, it should be available with the same name.

You can save data on disk different ways:

  • R ways is to serialize using saveRDS() (or readr::write_rds()) - this allows to have on R object stored in a file that R knows how to read using readRDS (or readr::read_rds()). Look at the documentation of this function

  • For data.frame you can use special object like fst (https://www.fstpackage.org/) or other cross language data format like parquet or feather using arrow (Function reference • Arrow R Package)

  • You can also write to file (CSV, JSON, ...) but it would then need to be parse and typed again.

RDS is the most commonly used format for storting R object to disk.