-
Notifications
You must be signed in to change notification settings - Fork 391
Closed as not planned
Closed as not planned
Copy link
Labels
Milestone
Description
Sometimes (especially with margin layout), it is useful to place the outputs of a code chunk side by side. To accomplish this, the outputs needs to come from the same chunk (e.g. a table of data and a plot of that data). It would be nice to be able to specify the labels for a chunk as an array, allowing something like:
```{r}
#| label: [tbl-cars, fig-cars]
#| fig-cap: "Cars fig"
#| tbl-cap" "Cars tbl"
#| tbl-column: margin
mtcars2 <- mtcars
mtcars2$am <- factor(
mtcars$am, labels = c('automatic', 'manual')
)
knitr::kable(
mtcars[1:6, 1:6]
)
library(ggplot2)
ggplot(mtcars2, aes(hp, mpg, color = am)) +
geom_point() + geom_smooth(formula = y ~ x, method = "loess") +
theme(legend.position = 'bottom')
```
Discussed in #1201
Originally posted by mvwestendorp June 22, 2022
Is it possible to switch the figure and table in this example? That is, the table in the margin and figure in the body.
Using #| tbl-column: margin does not seem to work in this case.