将图像插入数据表中一些闪亮的文本旁边

时间:2019-02-05 20:33:53

标签: css r shiny dt

我正在使用此示例曲棍球数据集(pbp_game_id):

structure(list(home_team = c("WPG", "PIT", "EDM", "S.J", "BOS", 
"BUF", "NYR", "OTT", "DET", "CHI"), away_team = c("TOR", "STL", 
"CGY", "PHI", "NSH", "MTL", "COL", "WSH", "MIN", "PIT")), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -10L))

比方说,我想在这些角色旁边插入冰球队标志,例如在以下示例中: enter image description here

我有一个包含一组31徽标的网址向量:

c("http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Ducks_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Coyotes_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Bruins_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Sabres_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/carolina.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_BlueJackets_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/calgary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/chicago.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/colorado.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Stars_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/detroit.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Oilers_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Panthers_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Kings_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Wild_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/montreal.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/newjersey.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Predators_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NY-Islanders-Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/newyorkr.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Senators_Primary.png", 
"http://www.stickpng.com/assets/images/5a4fbba3da2b4f099b95da1a.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Penguins_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Sharks_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/stlouis.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Lightning_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_MapleLeafs_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/Vancouver_Canucks.png", 
"https://upload.wikimedia.org/wikipedia/en/thumb/a/ac/Vegas_Golden_Knights_logo.svg/184px-Vegas_Golden_Knights_logo.svg.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Jets_Primary.png", 
"http://www.capsinfo.com/images/NHL_Team_Logos/NHL_Capitals_Primary.png"
)

我尝试过在文本旁边插入网址图片:

pbp_game_id %>%
   mutate(home_team = case_when(
    home_team == "ANA" ~ paste(team_logo[1], home_team),
    ...)

骨架UI

fluidRow(...
         column(4,
           DT::dataTableOutput("game_id_table"))

服务器

 # Game ID Table
  output$game_id_table <- DT::renderDataTable({

    DT::datatable(pbp_game_id, extensions = "Scroller",
                  filter = "top", options = list(
                    deferRender = TRUE,
                    scrollY = 200,
                    scroller = TRUE
                  ),
                  rownames = FALSE,
                  colnames = c("Game ID",
                               "Game Date",
                               "Home",
                               "Away")
    )

我在数据表上看不到任何图像。我只是看到普通网址... 我想念什么?

0 个答案:

没有答案