dt

How to avoid mixup between rowcallback and sorting in datatable

廉价感情. 提交于 2019-12-07 09:48:44
问题 With the help of a previous question, I can now style selected rows (intended for the user to select rows to be excluded from further analysis), but I have found out that sorting the datatable after executing the functionality to exclude rows (gray them out and add a different icon, keeps the icon in the correct row, but grays out the wrong rows. here is the table after deselecting rows 2,3 and 4 before sorting: and after sort: (with the crosses at the right rows, but the graying out not.

Shiny DT: Freeze rownames while sorting?

冷暖自知 提交于 2019-12-07 09:21:07
问题 I'm designing a Shiny app to rank people based on a variety of metics. Using the DT sorting feature, I want users to be able to click on any column and sort by it. It seems natural to use the rownames as the rank; the problem is that these numbers sort along with the rest of the table. Is there any way to freeze this column so the rank numbers stay the same while the rest of the table sorts? Perhaps with a JavaScript function? EDIT: In the example below, when I click "Metric_1," I want the

Conditional vertical scrolling in datatables embedded in a shiny app

拥有回忆 提交于 2019-12-07 03:54:14
问题 Actual questions I have a DataTable interfaced/created via DT::datatable and rendered via DT::renderDataTable. How do I conditionally enable vertical scrolling by basing the decision on the value of shiny::checkboxInput? How do I control the height of my datatable when vertical scrolling is enabled? I'm a bit at loss with exactly understanding the implications of options scrollY and scrollCollapse and their interaction with other options of DT::renderDataTable or the app itself (e.g. vertical

R datatable: Hide search box for individual columns

最后都变了- 提交于 2019-12-07 03:46:15
问题 I would like to enable searching by columns but disable it for particular columns. Here is almost what I need https://rstudio.github.io/DT/009-searchable.html but I would like to hide the unused boxes. Any way to do that? 回答1: You use CSS with a selector on the disabled inputs of type search to hide them. Here's an example in a shiny app: library(shiny) shinyApp( ui = fluidPage(tags$head(tags$style( HTML("input[type='search']:disabled {visibility:hidden}") )), DT::dataTableOutput('tbl')),

How can I reduce row height in DT datatables

别来无恙 提交于 2019-12-06 23:37:19
问题 I would like to be able to get 'slimmer' rows when rendering a DT datatable (ie decrease that height) options(digits.secs=6) library(data.table) d = data.table(x = 1:10,time = as.POSIXct('2015-03-23 12:00:00.123')) library(DT) datatable(d) 回答1: If you add the pageLength= attribute you can set how many rows to show initially. And by adjusting the lengthMenu= c() you can also control the sizes of offered in the drop down, You can also turn search on or off with searching =FALSE library(DT)

DT datatable selected row color: inconsistent behavior on IE and chrome

做~自己de王妃 提交于 2019-12-06 12:23:09
问题 I have an app, similar to below, which I'd like to customize the color of the selected row rendered via DT. My app code looks like below library(shiny) library(DT) bkg_shade <-"#2c3e50" ui <- fluidPage( tags$style(HTML(paste0("table.dataTable tr.selected td, table.dataTable td.selected{background-color: ", bkg_shade," !important;}"))), fluidRow(dataTableOutput("tbl")) ) server <- function(input, output){ output$tbl <- renderDataTable({ datatable(mtcars) }) } app <- shinyApp(ui = ui, server=

Hyperlink from one DataTable to another in Shiny

六月ゝ 毕业季﹏ 提交于 2019-12-06 11:44:24
问题 I have a Shiny app that consists of two pages: Page 1 displays a DataTable with summary information ( ensembles ). Page 2 displays detailed pricing info ( items ) for a specific ensemble, which is selectable. When the user clicks on a row on page 1, I want them to be taken to page 2, with the corresponding ensemble selected. The below code creates the Shiny app and the two pages, but requires the user to switch pages and enter the ensemble number manually. app.R library(shiny) ## Create item

Set names of values in lengthMenu (Page Length Menu) in R DT datatable

不羁岁月 提交于 2019-12-06 09:58:51
问题 I am making a datatable using the R DT package. I would like for the user to be able to decide/control whether to see 24, 48, 72, 96 or all rows in the data. This can be easily done by setting: lengthMenu = c(24,48, 72, 96, -1), in the option list, where -1 stands for all entries. Problem is that the user might not know what -1 stands for, and I would therefore like to make it appear as the string "All" in the menu visible to the user. By looking at the documentation for lengthMenu, I see

Highlight part of a string in a cell content based on a filter value

こ雲淡風輕ζ 提交于 2019-12-06 08:48:28
As the next step to the example provided in http://rstudio.github.io/DT/010-style.html I wish to highlight a part of a string in a cell based on a filter value as shown in the image below. I am trying to highlight specific motifs in biological sequence data in table format. Given below is the Excel VBA code and a representative image. Is it possible to achieve this in R? Sub SequencePartColourMacro() Dim Col, Row, FirstRow, LastRow As Integer, Col As Long Col = 6 FirstRow = 2 LastRow = ThisWorkbook.Sheets("Sequences").Cells(Rows.Count, "F").End(xlUp).Row Test1 = "CC" Test2 = "TT" Test3 = "GG"

R Shiny DataTables: Format numbers not by column but by row

ぃ、小莉子 提交于 2019-12-06 08:39:52
My data is a matrix like this: Buy and Hold Strategy [1,] 1.0000000000000000 19.0000000000000000 [2,] -0.6300786023496699 -0.2361973739022651 [3,] -0.0872213557701079 -0.0244237977843418 [4,] -0.3461103323781194 -0.1010012410191289 [5,] 0.0000000000000000 0.4949083503054990 [6,] 0.2520044841505053 0.2418168087629348 [7,] -0.7946470924762163 -0.7731378277502762 [8,] 1864.0000000000000000 1707.0000000000000000 As you see I need a formatting by row and not by column. For example [1,] should be without decimals, so there is a 1 and a 19. However Rows [2,]-Row[7,] should be a percentage like xx.x%