I have a dataframe of orders assigned to different people:
x<-data.frame(id = c("AAA", "AAA", "AAA", "BBB", "BBB", "CCC"),
name = c("Alice", "Alice", "Alice", "Bob", "Bob", "Charlie"),
prod = c("T-Shirt", "Pants", "Socks", "Socks", "Pants", "T-Shirt"))
which I would like to display in a Shiny application. Here is a MRE:
library(shiny)
library(tidyverse)
runApp(list(
ui = basicPage(
dataTableOutput('mytable')
),
server = function(input, output) {
output$mytable = renderDataTable({
x
})
}
))
Although this example displays the data exactly as expected given the data frame, I was wondering if it would be possible to change how the data are displayed to the end user (to aid legibility).
I would like the table to be grouped by id
so that the first row of each id
contains all information (across rows) before carriage-returning the products in the prod
column. When the next unique id
is reached, a new row would be created. I would like the output to look like this: