我正在尝试在闪亮的表格输出中使用千位分隔符。以下是我的代码:
UI <- dashboardPage(
dashboardBody(
fluidPage(
selectInput(inputId = "TableName",
label = "Select Data of Interest",
choices = list.files(path = "CSVData", pattern = "AMD_")),
uiOutput("Channel"),
formattableOutput("ResultTable")
)
)
)
Server <- function(input, output){
output$Channel <- renderUI({
df <- read.csv(paste("Pathname/",input$TableName, sep = ""))
selectInput(inputId = "ChannelSelect",
label = "Select Channel:",
choices = unique(df) %>% select(Channel))),
selected = NULL, multiple = FALSE)
})
output$ResultTable <- renderFormattable({
df <- read.csv(paste("CSVData/",input$TableName, sep = ""))
ChanSelect <- input$ChannelSelect
A1 <- df %>% filter(if(ChanSelect != "All") (Channel == ChanSelect) else TRUE) %>%
select(Channel, Amount)
formattable(A1, list(
`Amount` = comma(`Amount`, digits = 0, format = "f", big.mark = ","
))
})
}
我的 df 多种多样,但都采用以下格式:
data.frame("Channel" = c("A", "B", "C", "D"),
"Amount" = c(1000000, 2000000, 3000000, 4000000 ))
问题在于它不起作用的可格式化部分。我不知道如何comma()
正确输入函数formattable
。