假设我有以下闪亮的应用程序:
library(shiny)
library(rhandsontable)
ui <- shinyUI(fluidPage(
titlePanel("Handsontable"),
sidebarLayout(
sidebarPanel(
helpText("Handsontable demo output. Column add/delete does work ",
"for tables with defined column properties, including type."),
radioButtons("useType", "Use Data Types", c("TRUE", "FALSE"))
),
mainPanel(
rHandsontableOutput("hot", width = 350)
)
)
))
server <- shinyServer(function(input, output, session) {
values = reactiveValues()
data = reactive({
if (!is.null(input$hot)) {
DF = hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF = data.frame(val = 1:10, bool = TRUE, nm = LETTERS[1:10],
dt = seq(from = Sys.Date(), by …Run Code Online (Sandbox Code Playgroud) 我有一个使用 Rhandsontable 渲染的表格。我想将特定列的字体颜色更改为红色。我该怎么做 ?我尝试了以下代码,但它不起作用
output$hot=renderRHandsontable({
rhandontable (table)%>%
hot_col("colum1", color = "red")
})
Run Code Online (Sandbox Code Playgroud) 我想根据值对整行应用颜色突出显示,并保留 rhandsontable 的复选框功能。在下面的简单示例中,我希望第 3 行为粉色,第 4 行为绿色。
library(rhandsontable)
DF = data.frame( bool = TRUE,val = 1:10, big = LETTERS[1:10],
small = letters[1:10],
stringsAsFactors = FALSE)
###Checkboxes not Present/Entire row not highlighted
rhandsontable(DF, readOnly = FALSE, width = 750, height = 300) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, arguments);
if (value == 'C') {
td.style.background = 'pink';
} else if (value == 'D') {
td.style.background = 'green';
}
}")
####Checkboxes Present
rhandsontable(DF, readOnly …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个闪亮的应用程序,其中有一个rhandsontable。如果选择/检查另一列中的相应值,我希望 rhandsontable 能够更新其其中一列中的值。到目前为止,我已经能够使用反应/观察事件来更改两个对象之间的输出值,但我无法理解它,即,如何使 rhandsontable 的一列对同一个表中的另一列做出反应?
这是我正在尝试构建的一个简单示例:
library(shiny)
library(rhandsontable)
ui <- fluidPage(
rHandsontableOutput('table')
)
server <- function(input,output,session)({
data <- data.frame(c1=c(5,10,15), c2=c(3,6,9) , diff=c(0,0,0), select= as.logical( c(FALSE,FALSE,FALSE)))
output$table <- renderRHandsontable({
rhandsontable(data)
})
})
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
因此,如果我检查“Select”列,“diff”列应该产生列 c1 和 c2 之间的差异
在R中使用模块时,我的反应性存在问题。如果我更新一个模块,然后尝试使用这些更新的值更新另一个模块,那么我会在更新之前获取这些值。
我已经写了一些基本代码来说明我的意思。在这里,我有一个应用程序,该应用程序更新rHandsontableOutput放置在称为的模块中的位置my_module ,然后在按下按钮时将此更新复制rHandsontableOutput到称为第二个模块module_to_update的位置。
我发现的是的第一个表my_module将更新,而不会更新module_to_update。相反,该module_to_update表将在update之前收到my_module的初始表的副本。如果我再次按下更新按钮,则一切正常。
我猜测这与我如何处理会话或响应值有关,但我没有主意。
问题:如何设置反应值和模块,以便可以在同一函数调用中对更新的模块数据运行操作?(例如,请参见observeEvent(input$update_btn, ...)下面的电话示例)
应用程序
library(shiny)
library(rhandsontable)
source('my_modules.R')
active_tab = ""
ui <- navbarPage("Module Test Tool",
tabsetPanel(id = 'mainTabset',
tabPanel("My Tab",
#This is the HoT that works as expected, updating when called upon
h4("Table 1"),
myModuleUI('my_module'),
#This is the HoT that does NOT work as expected. This HoT fails to use the updated …Run Code Online (Sandbox Code Playgroud) 如何在 r 的闪亮包中的 rhandsontable 中使列标题粗体文本?
我有一个闪亮的 rhandsontable,我想将标题中的文本加粗。我该怎么做?有人知道吗?
我有一个 Shiny 应用程序,它可以读取 .csv 文件并生成一个可编辑的表格。
library(dplyr)
library(rhandsontable)
options(shiny.maxRequestSize = 9*1024^2)
function(input, output) {
values <- reactiveValues()
Post <- c("Bank", "Bank")
list2 <- c(12,13)
df <- data.frame(Post, list2)
Post <- c("Ba", "Ba")
list2 <- c(12,13)
df2 <- data.frame(Post, list2)
performTextMining <- reactive({
df$Post <- as.character(df$Post)
df <- df %>% filter(Post == "Bank")
return(df)
})
output$contents <- renderRHandsontable({
items <- c("Boodschappen", "Noodzakelijk")
inFile <- input$file1
if (is.null(inFile))
return(NULL)
df <- read.csv(inFile$datapath, header = input$header,
sep = input$sep, quote = input$quote)
#performTextMining()
rhandsontable(df, …Run Code Online (Sandbox Code Playgroud)