Skip to content

Instantly share code, notes, and snippets.

View Gotfrid's full-sized avatar
💭
The R Inferno

Pavel Demin Gotfrid

💭
The R Inferno
  • Appsilon
  • Portugal
View GitHub Profile
# create two simple dt with same order
dt1 = data.table(k = c(1:10),
v1 = rnorm(10),
key = "k")
dt2 = data.table(k = c(1:10),
v2 = rnorm(10),
key = "k")
# change order of dt1
@Gotfrid
Gotfrid / minimal_example.R
Last active June 21, 2021 07:51
Minimal reproducible example to test reactivity of selectInput with updateSelectInput
# app prototype -----------------------------------------------------------
library(shiny)
# define select chioces
input_choices <- data.frame(
x = c(1, 1, 2, 2, 3, 3),
y = c(11, 12, 21, 22, 31, 32)
)
# choices for x
@Gotfrid
Gotfrid / loop_bench.R
Created February 17, 2022 15:15
Compare various ways of loading multiple files
# Create test data
lapply(1:9, function(x) {
write.csv(
nycflights13::flights,
paste0("data", x, ".csv")
)
})
# List all files to iterate through
@Gotfrid
Gotfrid / searchable_dropdown.R
Last active December 13, 2023 03:53
shiny.fluent Dropdown component with search capabilities
box::use(
shiny[div, moduleServer, NS, observeEvent],
shiny.fluent[JS, fluentPage, Dropdown.shinyInput],
)
DropdownMenuItemType <- function(type) { # nolint
JS(paste0("jsmodule['@fluentui/react'].DropdownMenuItemType."), type)
}
render_search_box <- JS(paste("(option) => {