textbox - Insert a numeric input for each row - R Shiny -
i have complex code generates big matrix, here attach simple, reproducible example in order explain want: here's code:
# ui.r library(shiny) shinyui( mainpanel("table output", (tableoutput("my_table"))) ) # server.r library(shiny) shinyserver(function(input, output, session) { my_table = matrix( c(1:100), nrow=20, ncol=5) output$my_table <- rendertable(my_table) })
my goal put on left , right sides of table small textbox, one each row of table. in idea need able write number inside left textbox, on right textbox , calculations on row, based on number manually inserted. of course length of table vary therefore need use dim(my_table) in order put 1 small textbox each row, 1 on left side , 1 on right. thought use r shiny's numericinput function can't clue on how apply in scenario.
can r shiny functions or forced use html ui.r ?
any appreciated, thanks.
you can bind matrix 2 vectors of strings of html tags numeric inputs (input1 , input2 in code bellow), , add sanitize.text.function
evaluate html tags (and not strings).
for example :
shiny::runapp(list( ui = basicpage( tableoutput("my_table") ), server = function(input, output, session) { my_table = matrix( c(1:100), nrow=20, ncol=5) output$my_table <- rendertable({ input1 <- paste0("<input id='a", 1:nrow(my_table), "' class='shiny-bound-input' type='number' style='width: 50px;'>") input2 <- paste0("<input id='b", 1:nrow(my_table), "' class='shiny-bound-input' type='number' style='width: 50px;'>") cbind(input1, my_table, input2) }, sanitize.text.function = function(x) x) } ))
Comments
Post a Comment