我想制作一张闪亮的桌子,用星星符号而不是评分数字,但我会选择NA。
库(有光泽)
nba <- data.frame(
player = c("James", "Durant", "Curry", "Harden", "Paul", "Wade"),
team = c("CLEOH", "GSWOAK", "GSWOAK", "HOUTX", "HOUTX", "CLEOH"),
day1points = c("25","23","30","41","26","20"),
day2points = c("24","25","33","45","26","23"),
rating=c("1","2","3","4","5","1")
)
strrep("\U2605", as.numeric(nba$rating))
ui <- navbarPage(
title="SADDAS",
sidebarLayout(
sidebarPanel(uiOutput("var1_select")),
mainPanel(tableOutput("reportOutput"))
))
server <- function(input, output) {
output$var1_select<-renderUI({
selectInput("ind_var_select","Select Names", choices =c(as.character(nba[,1] )),multiple = TRUE,selected = nba[1,1])
})
output$reportOutput = renderTable({
nba[,1:5][nba$player %in% input$ind_var_select,]
},
options = list(scrollX = TRUE)
)
}
shinyApp(ui, server)
答案 0 :(得分:1)
一个选项是strrep
nba$rating <- strrep("*", nba$rating)
nba$rating
#[1] "*" "**" "***" "****" "*****" "*"
我们可以通过查看Utf符号来使用花哨的星星
strrep("\U2605", nba$rating)
#[1] "★" "★★" "★★★" "★★★★" "★★★★★" "★"
或者如果我们需要白星
strrep("\U2606", nba$rating)
#[1] "☆" "☆☆" "☆☆☆" "☆☆☆☆" "☆☆☆☆☆" "☆"