I am using R and ojs code chunks in a quarto document where I do data manipulation in R and the pass the data frame to the ojs chunk by using the ojs_define function.
My issue is that date seems to be interpreted as string in ojs chunk. The result is bad formatting in plots.
Any tips on how to pass a date from r to ojs in a way that the ojs plot function recognizes it as a date?
Example:
---
title: "Code example"
format: html
editor: visual
execute:
  echo: false
  warning: false
---
```{r}
#Some data with a date column
library(tidyverse)
df<-data.frame(day=seq.Date(from=as.Date('2023-01-01'), 
                            to=as.Date('2023-06-15'), 
                            by='days'))%>%
  mutate(values=rnorm(mean= 10, sd=2, n =n()))
#Passing this to ojs through ojs_define
ojs_define(plot_data=df)
```
```{ojs}
Chart = Plot.plot({
  marks: [
    Plot.line(transpose(plot_data), 
      {x: "day", y: "values"}, 
      { stroke: "black" }
    )
  ]}
)
```
