positron icon indicating copy to clipboard operation
positron copied to clipboard

Add code cells support for `knitr::spin()` syntax

Open juliasilge opened this issue 7 months ago • 3 comments

We already have support for code cells in R with syntax like this (similar to the Python support):


# %%
1 + 1

# %%
library(tidyverse)
diamonds |> 
  filter(carat > 2) |> 
  group_by(color) |> 
  summarise(price = median(price))

Let's consider adding additional, alternative syntax support in .R files for using the knitr::spin() support, as outlined:

  • https://quarto.org/docs/computations/render-scripts.html#knitr
  • https://bookdown.org/yihui/rmarkdown-cookbook/spin.html

juliasilge avatar May 16 '25 17:05 juliasilge

It would be really cool if cell options could be better integrated into positron

#| fig-width: 6
#| fig-height: 4
library(tidyverse)
diamonds |> 
  filter(carat > 2) |> 
  group_by(color) |> 
  summarise(price = median(price

would display a 6 x 4 image in the plots panel

kylebutts avatar May 17 '25 13:05 kylebutts

@kylebutts I believe we are tracking that in #3676, if you'd like to give a 👍 or add additional detail.

juliasilge avatar May 17 '25 18:05 juliasilge

@kylebutts shared some very useful context about this format in https://github.com/posit-dev/positron/pull/3858.

seeM avatar May 19 '25 10:05 seeM