Skip to contents

read_blocks() reads the values that write_blocks() wrote. In a knitr document, fake values put the mark **FAKE DATA** at the top of the output.

Usage

read_blocks(path, fake_attribute = "writeit_fake")

Arguments

path

The path of the blocks file.

fake_attribute

The name of the attribute that marks fake values. The values are fake when this attribute of the list is TRUE.

Value

The values: the list that write_blocks() wrote, with its attributes.

Details

When the values are fake and knitr renders a document, read_blocks() adds a knitr document hook. The hook puts **FAKE DATA** at the top of the output, after the YAML header when the output starts with one. It keeps the document hook that was there.

The knitr option paste0(fake_attribute, "_marked") records the hook, so a document gets the mark once, however many reads it does. knitr sets its options and hooks back at the end of each document. Outside knitr, and on values that are not fake, read_blocks() only reads.

Examples

path <- tempfile(fileext = ".qs2")
write_blocks(list(estimates = data.frame(term = "x", estimate = 1.2)), path)
read_blocks(path)
#> $estimates
#>   term estimate
#> 1    x      1.2
#> 
unlink(path)