I am working on a Shiny app that gets information from an API and displays that information in a table. Here is the code I have right now:
output$ItemInfo <- renderTable({
base <- "http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item="
item.id <- item.codes %>% filter(name == input$item)
url <- paste0(base, item.id$id)
item.data <- fromJSON(url)
table.data <- runescape.data %>% filter(ItemName == input$item)
image.url <- item.data[[1]]$icon_large[1]
Info <- c('Description', 'Image', 'Current Price (GP)', '% Change in Last 30 Days', '% Change in Last 90 Days', '% Change in Last 180 Days', 'Members Only', 'Low Alch', 'High Alch')
Data <- c(item.data[[1]]$description[[1]], paste0('<img src="', image.url, '"></img>'), item.data[[1]]$current$price, item.data[[1]]$day30$change, item.data[[1]]$day90$change, item.data[[1]]$day180$change, table.data$MembersOnly[[1]], table.data$LowAlch[[1]],
table.data$HighAlch[[1]])
#Display Both columns
return(data.frame(Info, Data))
})
I am getting a correct image.url
, I just cannot figure out how to render it. Currently this just displays code like <img src="http://services.runescape.com/m=itemdb_rs/1480946739712_obj_big.gif?id=560"></img>
where the actual image should be.
I also tried using this code as a replacement for the paste0
bit in on the Data
line: img(src='http://services.runescape.com/m=itemdb_rs/1480946739712_obj_big.gif?id=560', width = '300px', height = '100px')
, but this broke the entire table for some reason.
How can I go about rendering the images I get from this URL?