How to pass the data.frame in R to the array type in Stan

In R there is data.frame

library(tidyverse)
library(cmdstanr)

d <- palmerpenguins::penguins %>% 
  drop_na() %>% 
  select(bill_length_mm, bill_depth_mm)

d %>% head()
#> # A tibble: 6 × 2
#>   bill_length_mm bill_depth_mm
#>            <dbl>         <dbl>
#> 1           39.1          18.7
#> 2           39.5          17.4
#> 3           40.3          18  
#> 4           36.7          19.3
#> 5           39.3          20.6
#> 6           38.9          17.8

I want to run Multivariate Normal regression. However in Stan, array[N] vector[2] Y data need to be provided.

data {
  int N;
  int D;
  array[N] vector[D] Y; 
}

parameters {
  vector[D] mu_vec;
  cov_matrix[D] cov;
}

model {
  for (i in 1:N) {
    Y[i] ~ multi_normal(mu_vec, cov);
  }
}

How should I convert the data frame and construct type array[N] vector[2] Y ?

stan_data <- list(
  N = nrow(d), 
  D = 2, 
  Y =   
)

mod <- cmdstan_model(stan_file = stan_program)
fit <- mod$sample(data = stan_data)

Thank you very much for your help.

It works, but it’s a bit complicated

stan_data <- list(
  N = nrow(d), 
  D = 2, 
  Y = split(d, seq(nrow(d))) %>% map(as.numeric)
)

mod <- cmdstan_model(stan_file = stan_program)
fit <- mod$sample(data = stan_data)

or

stan_data <- list(
  N = nrow(d), 
  D = 2, 
  Y = d %>% t() %>% as.data.frame() %>% as.list()
)