我有一个数据透视表,它有从小数到百万的各种数字。我想添加格式,如大标记和小标记,以使数字更具可读性。有什么建议吗?
output$extPt <- renderPivottabler({
name <- c('a', 'b', 'c', 'd', 'e', 'f', 'g')
shortcut <- c('aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg')
counter <- c(1, 2, 3, 4, 5, 6, 7)
temp <- data.frame(name, counter)
extPt <- PivotTable$new()
extPt$addData(temp)
extPt$addColumnDataGroups("name")
extPt$addRowDataGroups("counter")
extPt$addRowDataGroups("shortcut")
extPt$evaluatePivot()
pivottabler(extPt)
extPt$defineCalculation(calculationName = "SumOfCounter", caption = "Sum of Counter",
summariseExpression = "sum(counter, na.rm=TRUE)", format = "%.2f")
})可能看起来像这样的东西:
1235,674.05
和0.12
和365222524.11
..。等
发布于 2021-03-05 02:02:59
尝试在汇总表达式中使用format()。
summariseExpression = "format(sum(counter, na.rm=TRUE), big.mark=',')"https://stackoverflow.com/questions/57511894
复制相似问题