dt

dateInput not working on DT in shiny

房东的猫 提交于 2019-12-01 00:39:52
I'm trying to create a DT with several inputs in Shiny. The columns with selectInput and numericInput work fine, but the one with dateInputs doesn't. It's like the input$date_n does not exist at all. I know close to nothing about JS, and I think the problem is probbaly in the drawCallback. I just copied this piece of code from another question in here, and it was working fine until I tried to use a dateInput. Below, there's a small code reproducing the problem. The first two outputs are OK, but the third just doesnst show up. library(shiny) library(DT) ui = fluidPage(title = 'Test', DTOutput(

How to hide a column using the DT package - columnDefs parameter doesn't work

♀尐吖头ヾ 提交于 2019-12-01 00:02:58
问题 I would like to hide a column (col4 in example below) in a dataframe using the DT package. I've incorporated the code snippet found here, to no avail - col4 still shows. Here is my sessionInfo, along with my reproducible example. > sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4

Render datatable with sparklines in Shiny

这一生的挚爱 提交于 2019-11-30 23:34:31
I want to include sparklines in a shiny DT. It works fine in the RStudio viewer but in Shiny the sparklines are not rendered. Here is a minimal example. # dependencies require(sparkline) require(DT) require(shiny) # create data with sparklines spark_data <- data.frame( id = c('spark1', 'spark2'), spark = c( spk_chr(values = 1:3, elementId = 'spark1'), spk_chr(values = 3:1, elementId = 'spark2') ) ) # render in RStudio viewer (this works) tbl <- datatable(spark_data, escape = FALSE) spk_add_deps(tbl) # render in Shiny (no sparklines rendered in DT) ui <- fluidPage( sparklineOutput("test_spark")

How do I get the data from the selected rows of a filtered datatable (DT)?

半世苍凉 提交于 2019-11-30 21:17:08
The DT package allows you to get the indices of selected rows using input$tableID_rows_selected . This works great for tables that do not have filtered data. However, if we have a filtered dataset, we can't use this same approach, as the row indices are off. For a filtered dataset, then, how would we get the data in the selected rows of a datatable? Below, I've posted a basic shiny app that shows four tables: the first one is the original mtcars dataset and the second gets the selected rows in the first. The third and the fourth do the same thing, but after filtering the dataset on the "filter

Shiny: Merge cells in DT::datatable

牧云@^-^@ 提交于 2019-11-30 20:39:41
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? 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("table") ) server <- function(input, output){ output[["table"]] <- renderDT({ dtable <- datatable(dat,

dateInput not working on DT in shiny

僤鯓⒐⒋嵵緔 提交于 2019-11-30 19:11:47
问题 I'm trying to create a DT with several inputs in Shiny. The columns with selectInput and numericInput work fine, but the one with dateInputs doesn't. It's like the input$date_n does not exist at all. I know close to nothing about JS, and I think the problem is probbaly in the drawCallback. I just copied this piece of code from another question in here, and it was working fine until I tried to use a dateInput. Below, there's a small code reproducing the problem. The first two outputs are OK,

Render datatable with sparklines in Shiny

帅比萌擦擦* 提交于 2019-11-30 17:46:04
问题 I want to include sparklines in a shiny DT. It works fine in the RStudio viewer but in Shiny the sparklines are not rendered. Here is a minimal example. # dependencies require(sparkline) require(DT) require(shiny) # create data with sparklines spark_data <- data.frame( id = c('spark1', 'spark2'), spark = c( spk_chr(values = 1:3, elementId = 'spark1'), spk_chr(values = 3:1, elementId = 'spark2') ) ) # render in RStudio viewer (this works) tbl <- datatable(spark_data, escape = FALSE) spk_add

shiny allowling users to choose which columns to display

瘦欲@ 提交于 2019-11-30 16:39:08
I am dabbling with the datatable feature in shiny and I am interested in creating a wellpanel or a sidepanel that lists all the columns of a datatable and allows users to choose which columns they want to see on the datatable. Right now this code below displays all the columns of toy dataset mtcars library(shiny) runApp(list( ui = basicPage( h2('The mtcars data'), dataTableOutput('mytable') ), server = function(input, output) { output$mytable = renderDataTable({ mtcars }) } )) I am interested in providing the users the ability to turn these columns either on or off using a checkbox [1] "mpg"

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

老子叫甜甜 提交于 2019-11-30 14:03:32
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! 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,0.794, .685, .456)) df1 <- df1 %>% mutate(A=round(A,digits=0)) datatable(df1) %>% formatPercentage('B', 2)

Shiny: use styleColorBar with data from two data frames

馋奶兔 提交于 2019-11-30 10:19:16
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)) print(pval_data) a } ) %>% formatStyle(names(a), background = styleColorBar(range(pval_data),