The used data, my request is the ui & server codes to replace each brand name in the column names with its logo using automatically.To ultimately get results exactly as the attached image
codes :
library(shiny)
library(data.table)
I made a dummy example to show you how it can be done, and you can adapt it to your full dataset.
library(shiny)
library(DT)
ui <- fluidPage(
dataTableOutput("myTable")
)
server <- function(input, output, session) {
#Get the list of manufacturer names and the link to the logo file
#File path can be online link or local image in www folder
logoList = list(opel = "<img height='50' src='https://cdn.iconscout.com/icon/free/png-256/opel-2-202862.png'></img>",
kia = "<img height='50' src='https://www.logospng.com/images/88/royal-azure-blue-kia-icon-free-car-logo-88484.png'></img>",
bmw = "<img height='50' src='https://cdn.iconscout.com/icon/free/png-256/bmw-4-202746.png'></img>")
#Create fake data (make sure the Manufacturer names match those in the logoList)
myData = reactiveVal(data.frame(Manufacturer = c("kia", "opel", "bmw", "opel"),
nCars = c(15, 85, 34, 16), stringsAsFactors = F))
output$myTable = renderDataTable({
#Swap the Manufacturer name for the image link
myData = myData()
myData$Manufacturer = unlist(logoList[myData$Manufacturer])
#Plot the table, make sure escape is false to interpret the string as HTML
datatable(myData, escape = FALSE)
})
}
shinyApp(ui, server)
Thanks for your time and effort @pieterjanvc '
when I Change the data line source from
myData = reactiveVal(data.frame(Manufacturer = c("kia", "opel", "bmw", "opel"),
nCars = c(15, 85, 34, 16), stringsAsFactors = F))
to
myData = reactiveVal(data.frame(Manufacturer = testmatrix))
#as the dataset name is "testmatrix"
no logos appear just normal table with only text.
bear with me, could you help me with example using excel file, just like my case ?
Thanks again, I am sorry for bothering you but I m beginner.