I have a table like below. I am grouping data by "name" and counting the records for each name. I want to add a sparkling using the "date" column to the table but haven't come across any documentation how to do that. I read about formattable R package but for that dates have to be in columns. I'll appreciate any help!
id name date
1 John 2018-05-30
2 John 2018-06-14
3 John 2018-06-15
4 John 2018-07-01
5 Miley 2018-01-01
6 Miley 2019-06-21
7 Miley 2020-05-19
This is how I am grouping. I now want to a another column to the table with the sparkline.
spark <- project %>%
group_by(name) %>%
summarise(
chart = spk_chr(
date,
type="line")
) %>%
gt() %>%
fmt_markdown(columns = vars(chart))
p_html <- gt:::as.tags.gt_tbl(spark)
p_html <- htmltools::attachDependencies(p_html, htmlwidgets::getDependency("sparkline"))
print(p_html, browse = interactive())
This produces an empty table.