Learn R Programming

mark (version 0.8.2)

eval_named_chunk: Evaluate a Named Chunk

Description

Evaluate a named chunk from an Rmd file.

Usage

eval_named_chunk(rmd_file, label_name)

Value

The value from the evaluated code chunk

Arguments

rmd_file

Absolute path to rmd file

label_name

Name of label

Examples

Run this code
temp_rmd <- tempfile(fileext = ".rmd")

text <- '
```{r not this label}
print("that is wrong")
```

```{r hello label}
text <- "hello, world"
print(text)
print(TRUE)
```

```{r another label}
warning("wrong label")
```
'
if (FALSE) {
writeLines(text, con = temp_rmd)

eval_named_chunk(temp_rmd, "hello label")
# [1] "hello, world"
# [1] TRUE

file.remove(temp_rmd)
}

Run the code above in your browser using DataLab