dreamrs / datamods Goto Github PK
View Code? Open in Web Editor NEWShiny modules to import and manipulate data into an application or addin
Home Page: https://dreamrs.github.io/datamods/
License: GNU General Public License v3.0
Shiny modules to import and manipulate data into an application or addin
Home Page: https://dreamrs.github.io/datamods/
License: GNU General Public License v3.0
the Filter functionality is great. I was wondering if it is possible to implement a way to remember the row selection if you tweak the filters?
Hi again Victor! I have another question - I've been trying to implement bookmarking while using the Select Group module and I haven't been able to get it working. The inputs appear in the URL string but don't load in the app when I try it. I've tried using onRestore() and onBookmark() to save the inputs as values (both in the app code and in the module code) but no luck there either. Any ideas of how I could get it working?
Explain usage of each module in README and vignettes
Goal: let user import an external file
Close to the one in {esquisse} : https://github.com/dreamRs/esquisse/blob/master/R/module-data-import-file.R
Features :
Do not support UTF-8 files?
Thanks a lot for your useful package!
I was wondering if it could be possible to pass other parameters to read_funs()
in import_file_server()
function?
In particular, I would like to specify the date format as '%d/%m/%Y' by default and specify custom na strings. I use the function to import Excel files (.xlsx or .xls).
Hi,
I'm using datamods to import files in my Shiny App with import_modal
function but the layout is now difference since I'm using the package bs4Dash
package for the dashboard layout.
Everything is working fine, it's just that the layout has been modified for the "Import / Print / Modification" options (see below):
A minimal reproducible example:
library(shiny)
library(datamods)
library(bs4Dash)
ui <- dashboardPage(
title = "Basic Dashboard",
header = dashboardHeader(),
sidebar = dashboardSidebar(),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
body = dashboardBody(
fluidPage(
# Try with different Bootstrap version
# theme = bslib::bs_theme(version = 4),
fluidRow(
column(
width = 4,
checkboxGroupInput(
inputId = "from",
label = "From",
choices = c("env", "file", "copypaste", "googlesheets", "url"),
selected = c("file", "copypaste")
),
actionButton("launch_modal", "Launch modal window")
),
column(
width = 8,
tags$b("Imported data:"),
verbatimTextOutput(outputId = "name"),
verbatimTextOutput(outputId = "data")
)
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$launch_modal, {
req(input$from)
import_modal(
id = "myid",
from = input$from,
title = "Import data to be used in application"
)
})
imported <- import_server("myid", return_class = "tbl_df")
output$name <- renderPrint({
req(imported$name())
imported$name()
})
output$data <- renderPrint({
req(imported$data())
imported$data()
})
}
if (interactive())
shinyApp(ui, server)
See example app here, which is the example given for import_file_server
except i added extra stuff to see the name
:
library(shiny)
library(datamods)
ui <- fluidPage(
tags$h3("Import data from a file"),
fluidRow(
column(
width = 4,
import_file_ui(
id = "myid",
file_extensions = c(".csv", ".txt", ".xls", ".xlsx", ".json")
)
),
column(
width = 8,
tags$b("Imported data:"),
verbatimTextOutput(outputId = "status"),
verbatimTextOutput(outputId = "data"),
verbatimTextOutput(outputId = "name")
)
)
)
server <- function(input, output, session) {
imported <- import_file_server(
id = "myid",
# Custom functions to read data
read_fns = list(
xls = function(file, sheet, skip, encoding) {
readxl::read_xls(path = file, sheet = sheet, skip = skip)
},
json = function(file) {
jsonlite::read_json(file, simplifyVector = TRUE)
}
)
)
output$status <- renderPrint({
imported$status()
})
output$data <- renderPrint({
imported$data()
})
output$name <- renderPrint({
imported$name()
})
}
shinyApp(ui, server)
When I uploaded example file, name
is still NULL even on success:
Hi Victor! Thank you so much for your work on the select_group
functions! I would like to use the selected inputs to filter more than one table, and am wondering if this is possible using select_group
.
I've found examples of using the input from one module as the input for a second module by including the inputs in the return from the first module's server function, and it looks like you've implemented something similar in filter_data_server()
. Would this be possible to implement in select_group_server()
, or is there another workaround you can think of that would allow me to re-use the inputs in another table?
Thank you!
Line 99 in 50eb6e5
Goal : convert a variable from a class to another (numeric -> character)
Also exist in {esquisse} : https://github.com/dreamRs/esquisse/blob/master/R/module-coerce.R
Hi, thanks for this useful package.
Would it be possible to include an optional argument to the filter function that sets the default value for the missing switch?
e.g. something like this:
filter_data_server <- function(id,
[...],
value_na = c(TRUE, FALSE),
label_na = "NA")
na_filter <- function(id, label = "NA", value = TRUE) {
tags$span(
style = "position: absolute; right: 0px; margin-right: -20px;",
prettySwitch(
inputId = id,
label = label,
value = value ,
slim = TRUE,
status = "primary",
inline = TRUE
)
)
}
When using datamods feature in esquisse (importing data) esquisse automatically removes rows with empty values instead of assigning NA values to them. I have experienced this with txt files. It shows the correct code after importing (and so admitting it has deleted the rows with empty values for a certain column).
Try yourself importing the attached file -> code after importing file: Pokemon_dataset.txt %>% filter(!(Type2 %in% ""))
Pokemon_dataset.txt
R version: 4.0.0
Esquisse version: 1.0.2.9000
FYI: this is not the case when reading the txt file in R with readr package and saving it as Rdata file. Then missing values are handled as expected (indication of 52% missing values for 'type2' without auto filtering it)
Hi,
Forgive me if this has already been addressed somewhere but this is my first Github contribution. In my own personal use when I use the "filter_data_server" and "filter_data_ui" functions, the dropdown selection for when I choose the "picker" option is not sorted. It is always in the order in which the choices appear in the data itself. I have found that if I alter the source code in the "filter-data.R" file by replacing "choices = choices" with "choices = sort(choices)" it works as intended.
Please let me know if this is useful information.
Hello !
I have an issue with import_modal when using dataset with big integers. (cf. example_datamods_import2.csv). It coerces them in "integer64" class by default. And this class raises non wanted behavior like in filter_data_server (each integer64 is a level), and others problems..
I have found it comes from the rio::import
function.
A = rio::import("example_datamods_import2.csv")
str(A)
'data.frame': 15 obs. of 16 variables:
$ s : chr "s1" "s2" "s3" "s4" ...
$ a : chr "AAA" "AAA" "AAA" "AAA" ...
$ c : chr "CCC" "CCC" "CCC" "CCC" ...
$ ech1 :integer64 4324150088420 7098787041658 6996576508743 2854821586954 8079962154898 6786661155549 4885674993226 8399970231393 ...
$ ech2 :integer64 6177848360239 1564036921714 8251207406512 1861954136736 4895263399550 7546132171258 2878401709191 5427114080957 ...
$ ech3 :integer64 4070473888567 8707956804603 82700196202 6520364487832 2638153702635 3953908527804 7403988297090 867957705851 ...
$ ech4 :integer64 8194090704667 4361200150732 6589967138421 92686922473 4815570846658 7643123561219 6334522093330 9686721632448 ...
$ ech5 : int 19422755 5335945 99341420 76470623 87582487 47455273 48850924 87200297 83070966 98942403 ...
$ ech6 : int 75757764 21074574 20675360 13812782 89267668 68649474 36804795 91947396 21548775 22385213 ...
$ ech7 : int 39756455 52969789 NA NA NA NA 85853419 33420566 81080277 NA ...
A = rio::import("example_datamods_import2.csv", integer64 = "numeric")
str(A)
'data.frame': 15 obs. of 16 variables:
$ s : chr "s1" "s2" "s3" "s4" ...
$ a : chr "AAA" "AAA" "AAA" "AAA" ...
$ c : chr "CCC" "CCC" "CCC" "CCC" ...
$ ech1 : num 4.32e+12 7.10e+12 7.00e+12 2.85e+12 8.08e+12 ...
$ ech2 : num 6.18e+12 1.56e+12 8.25e+12 1.86e+12 4.90e+12 ...
$ ech3 : num 4.07e+12 8.71e+12 8.27e+10 6.52e+12 2.64e+12 ...
$ ech4 : num 8.19e+12 4.36e+12 6.59e+12 9.27e+10 4.82e+12 ...
$ ech5 : int 19422755 5335945 99341420 76470623 87582487 47455273 48850924 87200297 83070966 98942403 ...
$ ech6 : int 75757764 21074574 20675360 13812782 89267668 68649474 36804795 91947396 21548775 22385213 ...
$ ech7 : int 39756455 52969789 NA NA NA NA 85853419 33420566 81080277 NA ...
$ ech8 : int 64611521 85800140 63846619 32782651 17559323 91555189 74940316 7894062 66450040 35083370 ...
is possible to control this parameter in the import_modal
function?
Thanks again
Etienne
Hi! Interested in using two of the modules here, the file import module , and the validation module . I was wondering if someone could provide me with a minimal example of how to use the two together. Namely, let user upload a data file and then run some validation against that data.
This would be really helpful! Thanks, and great package/modules!
-Kyle
Hi Victor,
I'm having trouble with passing select_group_ui
's params
options to Modal window. I was wondering what I'm missing here.
Shiny app reprex code:
library(shiny)
library(shiny.fluent)
library(datamods)
library(shinyWidgets)
ui_mod <- function(id) {
ns <- NS(id)
tagList(
reactOutput(ns("modal")),
PrimaryButton.shinyInput(ns("showModal"), text = "Show modal")
)
}
server_mod <- function(id) {
moduleServer(id, function(input, output, session) {
ns <- session$ns
modalVisible <- reactiveVal(FALSE)
observeEvent(input$showModal, modalVisible(TRUE))
observeEvent(input$hideModal, modalVisible(FALSE))
output$modal <- renderReact({
Modal(isOpen = modalVisible(),
Stack(tokens = list(padding = "15px", childrenGap = "10px"),
div(style = list(display = "flex"),
Text("Title", variant = "large"),
div(style = list(flexGrow = 1)),
IconButton.shinyInput(
ns("hideModal"),
iconProps = list(iconName = "Cancel")
),
),
div(
fluidRow(
column(
width = 10, offset = 1,
tags$h3("Filter data with select group module"),
shinyWidgets::panel(
select_group_ui(
id = "my-filters",
# params = NULL,
params = list(
list(inputId = "Manufacturer", label = "Manufacturer:"),
list(inputId = "Type", label = "Type:"),
list(inputId = "AirBags", label = "AirBags:"),
list(inputId = "DriveTrain", label = "DriveTrain:")
)
),
status = "primary"
) # ,
# reactable::reactableOutput(outputId = "table")
)
)
)
)
)
})
})
}
ui <- bslib::page(
ui_mod("test"),
reactable::reactableOutput(outputId = "table")
)
server <- function(input, output, session) {
server_mod("test")
res_mod <- select_group_server(
id = "my-filters",
data = reactive(MASS::Cars93),
vars = reactive(c("Manufacturer", "Type", "AirBags", "DriveTrain"))
)
output$table <- reactable::renderReactable({
reactable::reactable(res_mod())
})
}
shinyApp(ui, server)
This will be the output if we switch params
options to params = NULL
:
Thank you !
I am having a problem where empty items in my data are being filtered out, even when <empty fields>
is selected. This appears to be caused in filter-data.R, line 475:
if ("<empty field>" %in% values)
values[which(values == "<empty field>")] <- ""
Because the value is <empty field>
rather than <empty field>
I can make things work as expected with:
emptyField = as.character(as.tags("<empty field>"))
if(emptyField %in% values)
values[which(values == emptyField)] <- ""
But I suspect the "right" thing to do is make sure value is <empty field>
instead. But I'm not sure how to do that.
Hi Victor, just discovered this, looks like another terrific package from you!
I got a question regarding uploading data from an excel. Is it possible to upload data from multiple sheets at once?
I wish to combine datamods with Esquisse, ala
library(datamods)
library(esquisse)
ui <- fluidPage(
import_file_ui(id = "import_file"),
esquisserUI(id = "esquisse")
)
server <- function(input, output, session) {
imported <- import_file_server(id = "import_file")
data <- # ...imported...
callModule(
module = esquisserServer,
id = "esquisse",
data = data
)
}
shinyApp(ui, server)
It would appear imported
has the wrong structure to serve as data
for esquisserServer
. Even after extensive trial and error, I haven't found success. Could you perhaps shed some light on this?
Hi
Is it possible to have an argument file_extensions
in the import_modal()
function to control list of possible file formats allowed?
Thanks!
Etienne
Hi,
I cannot get select_group_ui()
and select_group_server()
get to work inside a shiny module.
I added ns()
to the IDs but possibly the virtualSelectInput()
s can't communicate properly due to wrong namespaces.
I suggest this feature is not implemented, or am I missing something important?
The following minimal example is the standard example from the help page, with the difference that I change the code so that the select_group_ui()
and -server()
are used inside a module.
Any help would be appreciated.
library(shiny)
library(datamods)
library(shinyWidgets)
myModuleUI <- function(id){
ns <- NS(id)
fluidRow(
column(
width = 10, offset = 1,
tags$h3("Filter data with select group module"),
shinyWidgets::panel(
select_group_ui(
id = ns("my-filters"),
params = list(
list(inputId = ns("Manufacturer"), label = "Manufacturer:"),
list(inputId = ns("Type"), label = "Type:"),
list(inputId = ns("AirBags"), label = "AirBags:"),
list(inputId = ns("DriveTrain"), label = "DriveTrain:")
)
),
status = "primary"
),
reactable::reactableOutput(outputId = ns("table"))
)
)
}
myModuleServer <- function(id){
moduleServer(id, function(input, output, session){
res_mod <- select_group_server(
id = session$ns("my-filters"),
data = reactive(MASS::Cars93),
vars = reactive(c("Manufacturer", "Type", "AirBags", "DriveTrain"))
)
output$table <- reactable::renderReactable({
reactable::reactable(res_mod())
})
})
}
ui <- fluidPage(
# theme = bslib::bs_theme(version = 5L),
myModuleUI("id")
)
server <- function(input, output, session) {
myModuleServer("id")
}
shinyApp(ui, server)
I tried to develop the filtering example with another table showing in the app. Everything works fine until I set the filter option in the second table to "top" instead of "none" and using an eventReactive instead of an reactive (which is fine without the additional table)
Example:
`library(shiny)
library(shinyWidgets)
library(datamods)
library(tidyverse)
library(DT)
ui <- fluidPage(
actionButton('bt_load', label = 'Load Data', icon = icon("upload")),
fluidRow(
column(
width = 3,
filter_data_ui("filtering", max_height = "500px")
),
column(
width = 9,
DT::dataTableOutput(outputId = "dt_filter")
, DT::dataTableOutput(outputId = "dt_extra")
)
)
)
server <- function(input, output, session) {
data_test <- eventReactive(input$bt_load, {
#data_test <- reactive({
diamonds
})
res_filter <- filter_data_server(
id = "filtering",
data = data_test,
name = reactive("data_test"),
vars = reactive(NULL),
widget_num = "slider",
widget_date = "slider",
label_na = "Missing"
)
output$dt_filter <- DT::renderDT({
res_filter$filtered()
}, options = list(pageLength = 5))
output$dt_extra = DT::renderDataTable(datatable(iris, filter = 'top'))
}
shinyApp(ui, server)`
instead of
Tested with
R version 4.1.2 on Windows
DT_0.19, shiny_1.7.1, datamods_1.2.0
and
R version 3.5.1 Debian GNU/Linux 9
DT_0.18, shiny_1.5.0, datamods_1.2.0
Thanks for any help
Christine
Dear Team,
I have recently encountered the issue while using the {datamods}
filter module. The problem arises when the dataset contains a column "class" with the data type "POSIXct" "POSIXt"
that includes timestamps. Specifically, when utilizing the dateRangeInput
function, the last day's data is not displayed as expected.
To provide a clear understanding, I have included a sample dataset along with the corresponding reprex app code below:
data:
> dat
# A tibble: 8 x 2
ID TESTTM
<int> <dttm>
1 1 2018-06-09 11:50:00
2 2 2017-04-06 12:30:00
3 3 2018-01-23 23:59:00
4 4 2017-12-20 11:20:00
5 5 2018-03-18 23:59:00
6 6 2017-12-29 12:12:00
7 7 2018-09-07 20:38:20
8 8 2018-09-07 23:59:00
sample data can be downloaded from here;
sample data
Shiny app reprex code;
# load packages
library(shiny)
library(datamods)
library(DT)
# read data
dat <- readRDS('dat.rds')
# ui
ui <- fluidPage(
tags$h3("Import data"),
fluidRow(
column(
width = 4,
filter_data_ui("filtering", max_height = "500px")
),
column(
width = 8,
tags$b("Imported data:"),
DT::dataTableOutput("mytable")
)
)
)
# server side
server <- function(input, output, session) {
res_filter <- filter_data_server(
id = "filtering",
data = reactive(dat),
name = reactive("dat"),
vars = reactive(names(dat))
, widget_char = c("select")
, widget_num = c("slider")
, widget_date = c("range")
, label_na = "empty_cell"
)
output$mytable = DT::renderDataTable({
res_filter$filtered()
})
}
# run app
shinyApp(ui, server)
Additionally, for your convenience, I have attached screenshots and the session info.
initial data;
last day data (selected 2018-09-07; app shows 0
output);
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C LC_TIME=English_India.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.28 datamods_1.4.1 shiny_1.7.4.1
loaded via a namespace (and not attached):
[1] zip_2.3.0 Rcpp_1.0.11 jquerylib_0.1.4 bslib_0.5.0
[5] cellranger_1.1.0 compiler_4.1.0 pillar_1.9.0 later_1.3.1
[9] shinyWidgets_0.7.6 forcats_1.0.0 phosphoricons_0.2.0 tools_4.1.0
[13] digest_0.6.33 memoise_2.0.1 jsonlite_1.8.7 lifecycle_1.0.3.9000
[17] tibble_3.2.1 pkgconfig_2.0.3 rlang_1.1.1 openxlsx_4.2.5.2
[21] cli_3.6.1 rstudioapi_0.15.0.9000 crosstalk_1.2.0 yaml_2.3.7
[25] writexl_1.4.2 curl_5.0.1 haven_2.5.3 rio_0.5.29
[29] fastmap_1.1.1 withr_2.5.0 sass_0.4.7 htmlwidgets_1.6.2
[33] vctrs_0.6.3 hms_1.1.3 reactable_0.4.4 glue_1.6.2
[37] data.table_1.14.8 R6_2.5.1 fansi_1.0.4 readxl_1.4.3
[41] foreign_0.8-81 magrittr_2.0.3 promises_1.2.0.1 ellipsis_0.3.2
[45] htmltools_0.5.5 rsconnect_1.0.1 mime_0.12 xtable_1.8-4
[49] httpuv_1.6.11 utf8_1.2.3 shinybusy_0.3.1 stringi_1.7.12
[53] cachem_1.0.8
Thank you for your attention to this matter.
I am trying to use the edit_data_server function to create a dataframe that I can then add rows to. The example works fine, but when i use my own dataframe I recieve this error:
Error in rbindlist(l, use.names, fill, idcol) :
Class attribute on column 3 of item 2 does not match with column 3 of item 1.
The dataframe I made is just a single row and column. I have tried it with other dataframes as well.
Here is the code:
library(shiny)
library(datamods)
library(bslib)
ui <- fluidPage(
theme = bs_theme(
version = 5
),
tags$h2(i18n("Edit data"), align = "center"),
edit_data_ui(id = "id"),
verbatimTextOutput("result")
)
dataframe_test <- data.frame('groupName' = 0)
server <- function(input, output, session) {
edited_r <- edit_data_server(
id = "id",
#data_r = reactive(demo_edit),
data_r = reactive(dataframe_test),
add = TRUE,
update = TRUE,
delete = TRUE,
download_csv = TRUE,
download_excel = TRUE,
file_name_export = "datas",
)
output$result <- renderPrint({
str(edited_r())
})
}
if (interactive())
shinyApp(ui, server)
Hello. I was wondering if in the UI there is a possibility to have no choices selected per default for factors when I start the application. I'm aware that there is the possibility to deselect all choices with the X on the right side, but it would be nice to be able to select that in the code. As far as I know the application always selects all choices for factors.
I have used the example under the "filter-data " section from the CRAN documentation (https://cran.r-roject.org/web/packages/datamods/datamods.pdf).
I have attached here the script I was using:
datamods_filter-data.txt
Thanks :)
I was trying to use filter_data_ui in my code and since It does not works I've tried to run the example. I keep getting the error
Error in filter_data_ui("filtering", max_height = "500px"): unused argument (max_height = "500px"). And if I get rid of the max height I get the more worrying error code Error: C stack usage 15923760 is too close to the limit
The info for my session
R Studio โ2023.6.1.524โ
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] clipr_0.8.0 installr_0.23.4 MASS_7.3-60 shinyWidgets_0.7.6 editData_0.1.8 datamods_1.4.1
[7] shiny_1.7.2
loaded via a namespace (and not attached):
[1] xfun_0.39 settings_0.2.7 bslib_0.5.0 haven_2.5.3 vctrs_0.6.1 miniUI_0.1.1.1
[7] htmltools_0.5.4 yaml_2.3.7 utf8_1.2.3 validate_1.1.3 rlang_1.1.0 jquerylib_0.1.4
[13] later_1.3.0 pillar_1.9.0 foreign_0.8-84 reactable_0.4.4 glue_1.6.2 withr_2.5.0
[19] reactR_0.4.4 readxl_1.4.2 lifecycle_1.0.3 stringr_1.5.0 cellranger_1.1.0 zip_2.3.0
[25] htmlwidgets_1.6.2 evaluate_0.21 memoise_2.0.1 knitr_1.43 rio_0.5.29 forcats_1.0.0
[31] fastmap_1.1.0 httpuv_1.6.6 curl_5.0.1 fansi_1.0.4 highr_0.10 Rcpp_1.0.9
[37] xtable_1.8-4 promises_1.2.0.1 DT_0.28 cachem_1.0.6 writexl_1.4.2 jsonlite_1.8.4
[43] mime_0.12 hms_1.1.3 digest_0.6.31 stringi_1.7.12 shinybusy_0.3.1 openxlsx_4.2.5.2
[49] grid_4.2.1 cli_3.4.1 tools_4.2.1 magrittr_2.0.3 sass_0.4.5 tibble_3.2.1
[55] pkgconfig_2.0.3 ellipsis_0.3.2 rsconnect_1.0.1 data.table_1.14.8 rstudioapi_0.15.0 phosphoricons_0.2.0
[61] R6_2.5.1 compiler_4.2.1
Goal : filter a data.frame
based on existing columns
Can copy the one in [esquisse} : https://github.com/dreamRs/esquisse/blob/master/R/module-filterDF.R
I'm seeing some unexpected filters in the safetyGraphics
shiny app when using the datamods
filter module. This is (relatively) new behavior was almost certainly introduced in a 2022 datamods
update.
I'll dig in more and try to debug in the next few days, but just wanted to check with you all to see if this was a known issue or if there's a new setting I need to tweak.
Thanks for any help (and for the great package)!
Hi !
I was wondering if there is any way to pass options to reactable for the edit module (for example to change column widths, change pagination etc).
If no, do you think adding this feature is possible ? How would you implement this ?
Thanks for the fantastic work on this package !
example
library(shiny)
library(shinyWidgets)
library(datamods)
library(MASS)
# Add some NAs to mpg
df <- data.frame(
a = c('a','b','c'),
b = c('d','e', '')
)
ui <- fluidPage(
filter_data_ui('aaa'),
textOutput('bbb')
)
server <- function(input, output, session) {
data <- reactive(df)
a <- filter_data_server('aaa', data)
output$bbb <- renderText({
toString(deparse(a$code()))
})
}
shinyApp(ui = ui, server = server)
even if the empty field is selected, "" is not included in filtered data
and if only empty field is selected, the code is not correct
sessionInfo
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MASS_7.3-60 datamods_1.4.0 shinyWidgets_0.7.6 shiny_1.7.4
loaded via a namespace (and not attached):
[1] zip_2.3.0 Rcpp_1.0.10 bslib_0.4.2
[4] compiler_4.2.2 cellranger_1.1.0 pillar_1.9.0
[7] later_1.3.1 jquerylib_0.1.4 forcats_1.0.0
[10] phosphoricons_0.2.0 tools_4.2.2 digest_0.6.31
[13] memoise_2.0.1 jsonlite_1.8.4 lifecycle_1.0.3
[16] tibble_3.2.1 pkgconfig_2.0.3 rlang_1.1.1
[19] openxlsx_4.2.5.2 cli_3.6.1 writexl_1.4.2
[22] curl_5.0.0 haven_2.5.2 rio_0.5.29
[25] fastmap_1.1.1 htmlwidgets_1.6.2 sass_0.4.6
[28] vctrs_0.6.2 hms_1.1.3 reactable_0.4.4
[31] glue_1.6.2 data.table_1.14.8 R6_2.5.1
[34] fansi_1.0.4 readxl_1.4.2 foreign_0.8-84
[37] magrittr_2.0.3 promises_1.2.0.1 ellipsis_0.3.2
[40] htmltools_0.5.5 mime_0.12 xtable_1.8-4
[43] httpuv_1.6.11 utf8_1.2.3 shinybusy_0.3.1
[46] stringi_1.7.12 cachem_1.0.8 crayon_1.5.2
Love this function, but I think I am running into a bug unless I have made some error in configuration.
If I import a single-column data source (as a data frame) before I adjust the sliders it displays the data. Once I move the dynamic filter sliders, I get an error from datatables that 'data must be 2-dimensional (e.g. data frame or matrix)'
It works perfectly for multiple column data.
It looks like the function is not returning a data frame for single columns - could that be possible? I have tried both integer and non-integer data.
Goal : Let the different import modules be called in a modal window.
With an argument to specify wich module use, and the ability to use more than one and let user select the one wanted.
Write unit tests for all functions.
See if we can use {shinytest}
I would like datamods to support getting and setting filter values so I can save and restore filters between sessions.
I have submitted a pull request which does this:
Goal : use a DBI connection to import a table
Features:
DBI::dbConnect
?Hello!
It would be nice to have the functionality to provide the import_file
module with a list of acceptable file extensions (.csv, .xlsx, etc), instead, by default, accepting everything. Let me know your thoughts.
Best,
-Kyle
Hello, really love the package, Thanks!
I was wondering if there's a way to place input filters in different parts of the App but referring to the same server.
Let me explain it better: I have many filters and I don't want to place all of them in a sidebar column. I need half of them there and the others at the top of the Main Panel, for example. Is that feasible as of now?
Alternatively, I was wondering if there's a way to have 2 pairs of UI/Server with different ids and still produce a coherent res_filter$filtered in the end?
As of now, the only thing I came up with is giving as data input of filters server number 1 the output of the filters server number 2 but this only works under one annoying condition: all the filters in the server number 2 have to be applied strictly before applying filters server number 1.
Some workaround idea?
Thanks,
Gaspare
Thank you for this great package, I thought, there should be an existing solution for such a common problem like reading in a data frame in an R GUI, and was surprised by the great options of datamods
. Thank you for that. However, I have a feature request here.
Many data sets are available as e.g. CSV files from URLs in the internet. With the file widget, I can only select local files, with the Google-Widget only Google spreadsheets. Since rio::import
also supports URLs in its file
argument (according to its manual, version 0.5.27), it should be a low-hanging fruit to have a widget for reading files from URLs.
Therefore, I would like to put a feature request here for a new import-class for external files.
Previously, my app would load text files with a .dat extension (usually they would be tab-delimited). Now it says " Ooops Format not supported"
Is there a way to add this functionality back? There are many legacy files that loaded just fine that I will have to change the extension on now if not.
Thanks again for an amazing package!
I am using esquisse::esquisser()
version 1.1.2
with R 4.1.2
on Linux.
With some datasets, there is a problem with the View
tab and it shows an error: Error: undefined columns selected
Steps to reproduce:
Import mtcars
from datasets
:
Klick on View:
The traceback looks like this:
Warning: Error in [.data.frame: undefined columns selected
112: stop
111: [.data.frame
105: <Anonymous>
103: callFunc
102: FUN
101: lapply
100: reactable::reactable
99: ::
htmlwidgets
shinyRenderWidget
98: func
85: renderFunc
84: output$esquisse-import-data-view
3: shiny::runApp
2: runGadget
1: esquisse::esquisser
Goal : import data.frame
from user environment
Features :
To do :
Goal : let user copy/paste some data to import
Features:
textarea
to let user paste some data then import it with {rio} or data.table::fread
Hi, I really love this package and what you are doing!
I have an issue with the filter_data_server(). I am trying to filter selected columns however I keep running into errors.
here's the example:
UI
shinyUI(
navbarPage("ShinybeetleNMR",
theme = shinytheme("yeti"),
tabPanel(
"input NMR files",
fluidPage(fluidRow(
column(
3,
import_file_ui("new_upload"),
update_variables_ui("var_update")
),
column(
3,
sliderInput("metadata_index", label = "group annotations columns", min = 1, max = 10, step = 1, value = c(1, 8)),
filter_data_ui("filtering_data", max_height = "500px")
)))))))
SERVER
shinyServer(function(input, output) {
#upload new data
new_data <- import_file_server(id = 'new_upload',btn_show_data = T,trigger_return = 'change', return_class = 'data.frame')
#update variables
new_variable <- update_variables_server('var_update',data = new_data$data)
#get the columns to filter from a slider input
metadata <- reactive({
names_to_filter <- colnames(new_variable()[,input$metadata_index[1]:input$metadata_index[2]])
names_to_filter
})
#filter the dataframe
filtered_data <- filter_data_server(id = 'filtering_data', data = new_variable, vars = metadata)
})
the error I get is:
Text to be written must be a length-one character vector
would you have any idea of why this is happening, I have tried different approaches but they all throw errors at me
Goal : import a Google sheet
Features :
Hi, thanks for awesome-package. it's really awe-some
i found
import_modal
supports csv
, txt
, xls
, xlsx
, rds
, fst
, sas7bdat
, sav
and import_file
supports these and custom extension using read_fns, like json
is there any option to customize these with import_modal
like import_file
?
(and if possible import-modal
's message like No file selected: You can import .csv, .txt, .xls, .xlsx, .rds, .fst, .sas7bdat, .sav files. because i found tsv
also supported !)
thanks in advance !
I found all shiny apps from package "datamods" failed to start after deployment in shinyapps.io.
For example, I got example codes form R help documents of "datamods" package:
library(shiny)
library(datamods)
ui <- fluidPage(
tags$h3("Import data from a file"),
fluidRow(
column(
width = 4,
import_file_ui(
id = "myid",
file_extensions = c(".csv", ".txt", ".xls", ".xlsx", ".json")
)
),
column(
width = 8,
tags$b("Import status:"),
verbatimTextOutput(outputId = "status"),
tags$b("Name:"),
verbatimTextOutput(outputId = "name"),
tags$b("Data:"),
verbatimTextOutput(outputId = "data")
)
)
)
server <- function(input, output, session) {
imported <- import_file_server(
id = "myid",
# Custom functions to read data
read_fns = list(
xls = function(file, sheet, skip, encoding) {
readxl::read_xls(path = file, sheet = sheet, skip = skip)
},
json = function(file) {
jsonlite::read_json(file, simplifyVector = TRUE)
}
),
show_data_in = "modal"
)
output$status <- renderPrint({
imported$status()
})
output$name <- renderPrint({
imported$name()
})
output$data <- renderPrint({
imported$data()
})
}
if (interactive())
shinyApp(ui, server)
It works in local Rstudio. However, after deploying the app to shinyapps.io, it says in the browser: "An error has occurred The application failed to start. exit status 1". The diagnostic information in Rstudio is : "Error detecting locale: Error in make.names(col.names, unique = TRUE): invalid multibyte string at '' (Using default: en_US) "
There is no problem with my other apps. But I found all examples from datamods package could not be deployed to shinyapps.io.
So how can I do with it? Is there any other packages to use in stead of datamods?
Goal : a module to select variables in a data.frame
There's already one in {esquisse} : https://github.com/dreamRs/esquisse/blob/master/R/module-select.R
But we can refactor it, maybe with a table with one row = one variable, and some infos about variables like in {skimr}
Can also be merged with convert/coerce module
I'm having issues loading .sas7bat
files using the import_file
module. Pretty sure the issue is with the dec
option. SAS files loaded as expected when I commented out this line, so I added an additional layer of ifelse()
in jwildfire/datamods
, which seems to clear up the issue. I'll file a PR shortly.
Thanks for the great package! We're using both the file load and filtering functionality extensively in the upcoming release of the safetyGraphics package. Prototype using {datamods} filtering here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.