Filtering dataframes with formattable

房东的猫 提交于 2019-12-05 17:34:33

Rescale from a subset of a data frame is a designed feature. If you really need to avoid rescale, you may try a currently available work-around:

subset_df <- function(m) {
  formattable(df[m, ], list(
    age = x ~ color_tile("white", "orange")(df$age)[m],
    test1_score = x ~ color_bar("pink", 0.2)(df$test1_score)[m],
    test2_score = x ~ color_bar("pink", 0.2)(df$test2_score)[m]
  ))
}

subset_df(1:5)
subset_df(c(1,3,5,9))
subset_df(df$age <= mean(df$age))

It basically forces the formatter functions of each column to apply to fixed data and filters the the produced formatted values with the same subset.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!