【发布时间】:2016-08-10 22:26:36
【问题描述】:
我发现我可以对 rhandonstable 进行数字格式化,也可以有条件地格式化 rhandsontable 的样式,但不能两者兼而有之。使用以下代码,似乎只使用了代码的 javascript 部分。对于合并这两种格式类型的任何帮助,我将不胜感激。
DF = data.frame(int = 1:10, float = rnorm(10), cur = rnorm(10) * 1E5,
lrg = rnorm(10) * 1E8, pct = rnorm(10))
rhandsontable(DF, width = 550, height = 300) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if (row == 2){
td.style.background = 'lightyellow';
}}") %>%
hot_col("float", format = "0.0") %>%
hot_col("cur", format = "$0,0.00") %>%
hot_col("lrg", format = "0a") %>%
hot_col("pct", format = "0%")
【问题讨论】:
标签: javascript r formatting handsontable