I would like to friendly ask that if anybody know how to make a certain variable name invisible in the selective area when using 'rpivotTable()' package in R?
For example, I build a pivot table using "UCBAdmission" data set:
# use rpivotTable to illustrate the effect
rp <- rpivotTable(UCBAdmissions, height=200)
However, if user accidentally drag "Freq" to "col" or "row" area, the table will be very big but this is not what I want.
So I would like to find a way to make "Freq" invisible from the selective area. I used the code here but this can only customize the whole table but not the individual variable.
style_widget <- function(hw=NULL, style="", addl_selector="") {
stopifnot(!is.null(hw), inherits(hw, "htmlwidget"))
# use current id of htmlwidget if already specified
elementId <- hw$elementId
if(is.null(elementId)) {
# borrow htmlwidgets unique id creator
elementId <- sprintf(
'htmlwidget-%s',
htmlwidgets:::createWidgetId()
)
hw$elementId <- elementId
}
htmlwidgets::prependContent(
hw,
htmltools::tags$style(
sprintf(
"#%s %s {%s}",
elementId,
addl_selector,
style
)
)
)
}
library(htmltools)
library(htmlwidgets)
library(rpivotTable)
# use rpivotTable to illustrate the effect
rp <- rpivotTable(UCBAdmissions, height=200)
browsable(
tagList(
rp,
style_widget(hw=rp, "font-family:monospace;"),
style_widget(hw=rp, "visibility:none;", "table td")
)
)
I don't know how to control the customize for individual variables. Does anyone know it or have any ideas about it?
I appreciate for any replies.
Thank you!
Best regards