dt

R shiny DataTables ColVis behavior

試著忘記壹切 提交于 2019-11-30 09:23:45
I got an RStudio Shiny server page with DataTables, and I got TableTools and ColReorder working in the example below, but ColVis ( Show/hide columns button) is not behaving in the same way as the example in http://datatables.net/extensions/colvis/ : When clicking the Show/hide columns button, the list mixes up with the values in the table underneath, and I cannot make the list disappear by clicking the button again or clicking anywhere else in the page (again, the example in the datatables page behaves correctly). Also, I am confused about using sDom to order the different elements in the

DataTables apply column formatting to filter also

独自空忆成欢 提交于 2019-11-30 07:22:13
When creating a datatable with filter = 'top' and also using a formatting function on a column, the formatting isn't applied to the filter control for that column. Is there a way to format the filter controls as well? For example, if I have floating-point numbers formatted as a percentage, the slider in the filter still shows floating point numbers. library(DT) my_data <- mtcars my_data$wt_pctile <- trunc(rank(my_data$wt)) / length(my_data$wt) datatable(my_data, filter = 'top') %>% formatPercentage('wt_pctile') Not sure if there's a way to do it. A workaround can be multiplying by 100: my_data

Shiny: Merge cells in DT::datatable

血红的双手。 提交于 2019-11-30 04:43:57
问题 I would like to merge few rows in column in DT::datatable in shiny. Is it possible to do so? Currently I am able to output which looks something like this: But ideally I would like to merge the rows and want to output something like this: Is it possible to merge rows like this in DT::datatable? 回答1: It is possible with the help of the datatables-rowsgroup library. Here is an example: library(shiny) library(DT) dat <- iris[c(1,2,3,51,52,53,101,102,103), c(5,1,2,3,4)] ui <- fluidPage( DTOutput(

styleColorBar Center and shift Left/Right dependent on Sign

我怕爱的太早我们不能终老 提交于 2019-11-30 00:45:32
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 on Excel; the colours aren't necessary but if included that would be a bonus. You could make a custom

Add comma to numbers every three digits in datatable (R)

旧街凉风 提交于 2019-11-29 19:21:00
问题 Suppose my data looks like this: df1 = data.frame(A=c(1000000.51,5000.33), B=c(0.565,0.794)) I want to use DataTables and have column A be (1,000,001 ; 5,000) library(DT) datatable(df1) %>% formatPercentage('B', 2) %>% formatRound('A',digits = 0) I know i can use scales library(scales) comma_format()(1000000) but I'm not sure how to combine that with DataTables Thanks! 回答1: Had this same issue: Try This: require(DT) require(dplyr) df1 = data.frame(A=c(1000000.51,5000.33, 2500, 251), B=c(0.565

Shiny: use styleColorBar with data from two data frames

浪尽此生 提交于 2019-11-29 15:53:14
问题 I am trying to display a table in Shiny, where numbers will be displayed from one data.frame (or data.table), but the size of bars will be taken from another data.frame. For instance, absolute values will be displayed, but -log(p-values) from another table (identically arranged) will determine the width of color bars. This is my mock code: output$pivot_table = DT::renderDataTable( dt <- datatable( { a <- data.frame(matrix(1, 20, 5)) pval_data <- data.frame(matrix(rnorm(n = 100), 20, byrow = T

R shiny DataTables ColVis behavior

孤街浪徒 提交于 2019-11-29 13:59:02
问题 I got an RStudio Shiny server page with DataTables, and I got TableTools and ColReorder working in the example below, but ColVis ( Show/hide columns button) is not behaving in the same way as the example in http://datatables.net/extensions/colvis/ : When clicking the Show/hide columns button, the list mixes up with the values in the table underneath, and I cannot make the list disappear by clicking the button again or clicking anywhere else in the page (again, the example in the datatables

R Shiny: Editing DT with locked columns

与世无争的帅哥 提交于 2019-11-29 11:36:51
I am trying to have a DT that is editable by the user but I only want certain columns to be editable. Since this isn't a feature yet in DT , I am trying to hack it together by having the table refresh back to the original value when edited a column that I want "locked". Below is my code: library (shiny) library (shinydashboard) library (DT) library (dplyr) library (data.table) rm(list=ls()) ###########################/ui.R/################################## #Header---- header <- dashboardHeaderPlus() #Left Sidebar---- sidebar <- dashboardSidebar() #Body---- body <- dashboardBody( useShinyjs(),

Include link to local html file in DataTable in Shiny

强颜欢笑 提交于 2019-11-29 08:54:35
I want to include a link to a local html file, which lives inside the www directory of my shiny app, inside a column in data.table. On click a new tab should open showing the html file. I've found solutions for linking to internet pages, but how do I adjust this, so that Shiny finds the local files, when rendered in a browser? This is my code library(DT) library(shiny) link <- "www/my_html.html" link <- paste0("<a href='", link,"' target='_blank'>", link,"</a>") # works fine for global url, but not for local file df <- data.frame(a = 10.5, b = 48, link = link) ui <- fluidPage( DT:

R Shiny, how to make datatable react to checkboxes in datatable

天涯浪子 提交于 2019-11-29 07:48:29
I would like my datatable to display content which depends on the status of checkboxes contained in the table. I have found help with both, including checkboxes in a DT as well as changing data table content, but when I try and combine these solutions I don't get what I want. When checking a box, the table is redrawn twice, the first time the way I want but a moment later it switches back. This is the code which should almost do... Is there someone out there to help before I get crazy? library(shiny) library(DT) shinyApp( ui = fluidPage( DT::dataTableOutput('x1'), verbatimTextOutput('x2') ),