我的问题是在“R”中,如何根据带有“ifelse () o another”的条件对值.pvtVal、元素进行着色?

问题描述

使用包“rPivotTable”和“htmlwidgets”

我的问题集中在如何使用以下条件为“女性”列着色:如果“女性> =男性”颜色为绿色,如果“女性

调节器的目的是能够像这张图片一样为单元格或单元格值着色enter image description here

enter image description here

    `prueba1<-rpivotTable(Titanic,rows = c("Survived","Class"),cols = c("Sex"),vals = c("Class","Freq"),rendererName = "Row Heatmap",rendererOptions = list(
     heatmap = list(
     colorScaleGenerator = htmlwidgets::JS('function(values) {
     return d3.scale.linear().domain([0,0.015,1])
     .range(["#FF0000","#FFFFFF","#14B904"])}'))),aggregatorName = "Eficiencia",locale= "en",aggregators = list(Eficiencia = htmlwidgets::JS('$.pivotUtilities.aggregators["Sum over Sum"]'),Suma = htmlwidgets::JS('$.pivotUtilities.aggregators["Sum"]')))

     prueba1$x$params$rendererOptions=prueba1$x$params$rendererOptions[[1]]`

      prueba1<-htmlwidgets::prependContent(prueba1,htmltools::tags$style(".pvtTotalLabel,.colTotal,hhv.rowTotal,.pvtGrandTotal { display: none; }"))

     prueba1`

我尝试使用以下命令对值进行着色,但没有得到满意的结果,我真的不知道如何将颜色调节器添加到 .pvtVal 或 td.pvtVal;

A. prueba1<-htmlwidgets::prependContent(prueba1,htmltools::tags$style("..pvtVal { cursor:pointer; color: red;}"))

B.函数首先生成“style_widget”,首先生成函数然后在包含pivotTable的对象上使用

prueba1<-browsable(tagList(#style_widget(hw=pivotdet,"font-family:monospace;"),style_widget(hw=pivotfert,"font-s|ize:100%; color: black; text-align: center;","table td.pvtVal")))

在将其导出为 HTML 报告时,是否可以在不使用颜色映射、使用“htmlwidgets”或“CSS”或使用 html 语言的情况下实现我想要获得的内容???

感谢您的意见和帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)