How to make knitr work with c.trellis?

136 Views Asked by At

With knitr I try to product and combine two lattice plots with c.trellis(), but instead of the expected combined plot I get what looks like the internal representation of the combined trellis object:

enter image description here

MWE:

---
title: "Knitr and c.trellis"
author: "David Lindelöf"
date: "17 February 2016"
output: pdf_document
---

```{r}
foo <- xyplot(1 ~ 1)
bar <- xyplot(2 ~ 1)
c(foo, bar)
```

I have also tried calling print(c(foo, bar)) in a separate chunk, without success. Am I doing something wrong, or is this an issue with knitr?

1

There are 1 best solutions below

1
On BEST ANSWER

I had forgotten to include a call to library(latticeExtra), which defined the c.trellis() method.