我想准备一个Shiny App,其中用户可以用数字填充一列(例如Col1),然后按一个按钮为Col2生成条目(引入Col1的值的转换,例如乘以Col1的每一行通过随机数)。 我应该如何将按钮添加到以下示例代码中:
Feign.builder()
.client(RibbonClient.create())
...
.requestInterceptor(new MyInterceptor())
答案 0 :(得分:0)
你在寻找类似的东西:
ui <- shinyUI(fluidPage(
titlePanel("Edit and save a table"),
sidebarLayout(
sidebarPanel(
helpText("Shiny app based on an example given in the rhandsontable package.",
"Right-click on the table to delete/insert rows.",
"Double-click on a cell to edit"),
wellPanel(
h3("Table options"),
radioButtons("useType", "Use Data Types", c("TRUE", "FALSE")),
actionButton("Calculate", "Calculate column 2")
),
br(),
wellPanel(
h3("Save"),
actionButton("save", "Save table")
),
wellPanel(
textOutput('result')
)
),
mainPanel(
rHandsontableOutput("hot")
)
)
))
server <- shinyServer(function(input, output) {
#extract data from the table to be used
portfoliovals2 <- reactive({
live_data = hot_to_r(input$hot)[,1]
return(live_data)
})
#extract data to be used
portfoliovalsB2 <- reactive({
live_data = hot_to_r(input$hot)[,2]
return(live_data)
})
## create a new df every time the table is modified
new_df_g <- reactive({
initial_dataEdit = portfoliovals2()
initial_dataEditB = portfoliovalsB2()
initial_dataEditW <- data.frame(initial_dataEdit, initial_dataEditB)
return(initial_dataEditW)
})
output$hot <- renderRHandsontable({
if (input$Calculate ==0){
initial_data = data.frame(Col1=1:10, Col2=runif(10), stringsAsFactors = FALSE)
} else {
initial_data = new_df_g()
initial_data <- plyr::rename(initial_data, c("initial_dataEdit"="Col1", "initial_dataEditB"="Col2"))
initial_data$Col2 <- initial_data$Col1 * 1.3
}
rhandsontable(initial_data, readOnly = FALSE, rowHeaders = NULL, height = 600) %>%
hot_cols(columnSorting = TRUE)
})
})
## Save
observeEvent(input$save, {
finalDF <- new_df_g()
saveRDS(finalDF, file=file.path(outdir, sprintf("%s.rds", outfilename)))
})
})
## run app
runApp(list(ui=ui, server=server))