Skip to contents

Register with rpic_register_knitr(), then write pic code in a chunk:

```{rpic, circuits=TRUE}
A:(0,0); B:(2,0)
resistor(A,B)
```

Chunk options: circuits, texlabels, scale.

Usage

rpic_knitr_engine(options)

Arguments

options

knitr chunk options.

Value

The chunk output produced by knitr::engine_output() (the rendered diagram as an included figure; with geo = TRUE, the source only).

Details

In an ordinary R chunk, a pic() object left visible is drawn as the chunk's figure as well (its knit_print() method), with no engine to register.

Maps (geo = TRUE)

With the chunk option geo = TRUE the chunk is georeferenced instead of drawn: the engine runs rpic_sf() (or rpic_geojson() when sf is not installed) and assigns the result to a variable in knitr::knit_global() — named by the chunk option geo.var, by default the chunk label made syntactic (make.names(), - read as _). The chunk emits no figure; its source is echoed as usual. The georeferencing options ride as geo.frame, geo.anchor, geo.scale, geo.bearing, geo.features, geo.flatten, geo.view_scale and geo.name_col (the geo. prefix keeps scale for the PNG raster scale); chunk options are R expressions, so geo.features = my_sf works. Plot the result in a later R chunk:

```{rpic, geo=TRUE}
geo_lon = -34.8711; geo_lat = -8.0631; geo_scale = 1000
circle rad 2 at (0, 0)
```

```{r}
ggplot2::ggplot(radius) + ggplot2::geom_sf(ggplot2::aes(fill = fill))
```

(the first chunk being labelled radius).