There is gt table Current Table , how can I change to Wished Table1 and Wished Table2?
(There are separated question) .Refer to attached image. Thanks!
library(tidyverse)
library(gt)
diamonds %>% head(5) %>% group_by(color) %>%
summarise(x=list(x),y=list(y)) %>% gt()
>Solution :
Using paste collapse:
library(gt)
library(dplyr)
ggplot2::diamonds %>%
head(5) %>%
group_by(color) %>%
summarise(x = paste(x, collapse = "_"),
y = paste(y, collapse = "_")) %>%
gt()
ggplot2::diamonds %>%
head(5) %>%
group_by(color) %>%
summarise(x = paste(x, collapse = "<br>"),
y = paste(y, collapse = "<br>")) %>%
gt() %>%
fmt_markdown(columns = c(x, y))


