I am using Rmarkdown for a project for the first time and one thing that is bugging me is the speed at which cells which are just function definitions run.

Below is an MWE function with lots of lines defined in a cell. It takes about a second to run when I click "run cell" in the rmarkdown viewer. Why? R parses very fast when reading from a script, and there is no evaluation happening here.

The parsing speed is worse for some larger functions I have written. Is there any way to have faster parsing?

```
```{r, echo = FALSE}
test_fun = function(){
df = tibble(a = runif(1000), b = runif(1000))
df = df %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b) %>%
mutate(c = a + b)
}
```
```