我正在尝试更改闪亮应用程序中数据表的页脚。我可以使用以下代码复制我在应用程序中遇到的错误:
dt_test <- tibble(cntry = c("A","A","B"),
city = c("X","Y","Z"),
sales = c(1000,1500,500),
score = c(1.1234,5.1234,2.1234))
footer <- sapply(dt_test, function(x) ifelse((is.numeric(x)), sum(x), ""))
sketch <- htmltools::withTags(table(
tableHeader(dt_test),
tableFooter(footer)
))
sketch
R 显示了这一点:
Error in writeImpl(text) :
Text to be written must be a length-one character vector
但是,如果我直接将页脚的定义作为参数,它会起作用:
sketch <- htmltools::withTags(table(
tableHeader(dt_test),
tableFooter(sapply(dt_test, function(x) ifelse( (is.numeric(x)),sum(x), "" ))
)))
不幸的是,我不能使用这种方法,因为聚合包含很多业务逻辑,并且在单独的函数中执行。我在这里做错了什么?