dt

In Shiny, update DataTable with new values from user input

僤鯓⒐⒋嵵緔 提交于 2020-01-13 03:56:26
问题 I'm writing a shiny app that has a table (using DT::renderDataTable ) from which users can select a row. But I want the user to also be able to add new row(s) if what they want is not already in the table. I'm using input controls for the user to enter new data, and I have an action button which, if pressed, should create a new row of data in the table from the input values. But pressing the button does not update the table. A minimal example: library(shiny) library(DT) mydata = data.frame(id

R datatable buttons export with formated cells

大兔子大兔子 提交于 2020-01-11 10:32:25
问题 The extensions Buttons works great for shiny application, from library(DT) . However it export the data without formatting. Is there a way to export data with format (e.g. percentage, or currency)? Similar question left unsolved. Reproducible code library(DT) data.frame(a = c(1,2), b = c(2,3)) %>% datatable(extensions = 'Buttons', options = list( dom = 'Bfrtip', buttons = c('copy', 'csv', 'excel', 'pdf', 'print')) )%>% formatPercentage('a') %>% formatCurrency('b') 回答1: Instead of using the

Image popup on hover in DT in R

拈花ヽ惹草 提交于 2020-01-11 08:50:11
问题 I have a DT within a Rmarkdown and I would like an image to pop up when hovering over table data. What i have so for seems to work but it distorts the datatable . It increases the table rows height to fit the image. I have tried to reduce the row sizes via css but with no luck. This is the Rmarkdown I have so far: --- title: "Untitled" author: "dimitris_ps" date: "3 September 2016" output: html_document --- <style type="text/css"> .imgTooltip { visibility: hidden; } .ItemsTooltip:hover

styleColorBar Center and shift Left/Right dependent on Sign

丶灬走出姿态 提交于 2020-01-10 07:42:20
问题 I am looking to create bars that when using DT's datatable appear in the middle of the cells of a column and reach out left or right depending on whether the value in the cell is positive or negative. I have tried using the function styleColorBar and changing the argument backgroundPosition to 'left' or 'center' however with each try the bars still appear to the right of the cell and always go to the left. I can't find an example from R code, but have attached an example of what can be done

Total of a column in DT dataTables in shiny

不问归期 提交于 2020-01-10 04:10:39
问题 I am trying to calculate the total of a column in my shiny app using DT::datatable. By total I mean the sum of all elements in a table not just what is showing in the current pagination. Following this example the following code should work (but it doesn't): jsCode <- "function(row, data, start, end, display) { var api = this.api(), data; total = api.column(1, {page: 'all'}).data().reduce( function(a, b) { return a + b}, 0); $( api.column(1).footer() ).html('Total: ' + total); }" All I am

Total of a column in DT dataTables in shiny

做~自己de王妃 提交于 2020-01-10 04:10:05
问题 I am trying to calculate the total of a column in my shiny app using DT::datatable. By total I mean the sum of all elements in a table not just what is showing in the current pagination. Following this example the following code should work (but it doesn't): jsCode <- "function(row, data, start, end, display) { var api = this.api(), data; total = api.column(1, {page: 'all'}).data().reduce( function(a, b) { return a + b}, 0); $( api.column(1).footer() ).html('Total: ' + total); }" All I am

Use backgroundColor in DT package to change a complete row instead of a single value

时间秒杀一切 提交于 2020-01-07 07:46:32
问题 The answer is probably obvious but i've been looking into using the backgroundColor attribute in the DT package to change the color of the full row instead of only the value that i use to select the row and I didn't manage to do it. So basically in my Shiny app, I have a DataTable output in my server file where i wrote this : output$tableMO <- DT::renderDataTable({ datatable(DFSurvieMO, options = list( displayStart= numerMO()-2, pageLength = 15, lengthChange = FALSE, searching =FALSE)

DataTables DT: reset value of clicked cell

我怕爱的太早我们不能终老 提交于 2020-01-07 02:57:13
问题 I wanted to add the functionality of something happening after a table cell was clicked (e.g. open a modal). Because (suppose my dt is has the ID "dt") input$dt_cell_clicked stays the same until I click a new cell, I cannot execute the same event on re-clicking that cell. I tried working around it resetting input$dt_cell_clicked with javascript manually. This works, but there seems to be an internal updatemarker in DT that noticed I clicked the cell before and does not set the value of input

Unresponsive slider

只谈情不闲聊 提交于 2020-01-04 18:39:28
问题 I have some data below and I would like to create sliders for years and months. I have a column with both the year and month. Also, I am new to shiny so this is quite new to me. Here’s what I tried: stack_qn <- structure(list(Date = c("2012-01", "2012-02", "2012-03", "2012-04", "2012-05", "2012-06", "2012-07", "2012-08", "2012-09", "2012-10", "2012-11", "2012-12", "2013-01", "2013-02", "2013-03", "2013-04", "2013-05", "2013-06", "2013-07", "2013-08", "2013-09", "2013-10", "2013-11", "2013-12"

R Shiny - Disabling specific rows in a datatable with column sorting

末鹿安然 提交于 2020-01-04 06:18:10
问题 The app below contains a datatable of the iris dataset with row selection enabled. I would like to disable selection for the first 3 rows specifically. I can do this using the solution posted here. The solution works fine when the table initialises on app startup: However, when you sort the rows on a column, e.g. on Species in descending order, it disables observations 101, 102 and 103 since they are now the first 3 rows of the table as a result of the sorting: I am guessing this happens