Skip to content

Instantly share code, notes, and snippets.

Avatar

Barbara Borges Ribeiro bborgesr

View GitHub Profile
@bborgesr
bborgesr / reset-fileInput-and-data.R
Created Mar 20, 2017
How to "reset" a fileInput widget and the underlying data (must treat these as two different things)
View reset-fileInput-and-data.R
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
fileInput('inFile', 'Choose file'),
actionButton('reset', 'Reset'),
tableOutput('tbl')
)
@bborgesr
bborgesr / reactives-in-loops.R
Created Mar 5, 2017
How to use reactives in loops. What works, what doesn't and why.
View reactives-in-loops.R
# -------------------------------------------------------------------
# ------------------ REACTIVES INSIDE FOR LOOPS ---------------------
# -------------------------------------------------------------------
# -------------------------------------------------------------------
# --- EXAMPLE 1: this works fine, because there are no reactives in -
# --- the for lopp --------------------------------------------------
# -------------------------------------------------------------------
library(shiny)
@bborgesr
bborgesr / pseudo-navigation-shiny.R
Created Jun 30, 2017
Implements pseudo navigation in a Shiny app
View pseudo-navigation-shiny.R
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
tags$a("Go to Panel 1", href = "#panel1"), br(),
tags$a("Go to Panel 2", href = "#panel2"), br(),
tags$a("Go to Panel 3", href = "#panel3")
),
mainPanel(
@bborgesr
bborgesr / shiny-reactive-R6-object.R
Created Aug 1, 2017
Uses the reactiveTrigger() construct in an R6 object class in order to make it useful in reactive settings, like a Shiny app (MWE included)
View shiny-reactive-R6-object.R
library(shiny)
reactiveTrigger <- function() {
counter <- reactiveVal( 0)
list(
depend = function() {
counter()
invisible()
},
trigger = function() {
@bborgesr
bborgesr / modular-processing.R
Created Mar 8, 2017
Processing input data, step by step, using Shiny modules
View modular-processing.R
# -------------------------------------------------------------------
# ------------------ PROCESSING DATA MODULARLY----------------------
# -------------------------------------------------------------------
# This app processes some input text through three modules, passing
# the result of each module down to the next module. We're also
# displaying to the user the (reactive) result of each module, but
# usually we'd just be interested in the last one... In those cases,
# the modules' ui functions would be empty (except for the last
# module, of course).
@bborgesr
bborgesr / dynamic-dropdownMenu.R
Created May 9, 2017
How to dynamically add items to a dropdownMenu in shinydashboard
View dynamic-dropdownMenu.R
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Dropdowns 2.0",
dropdownMenuOutput("menu")
),
dashboardSidebar(
helpText("Add another item to the dropdown menu by clicking ",
"on the button below"),
@bborgesr
bborgesr / simple-server.js
Created Feb 4, 2020
A simple server to serve mock data for the Room Manager app (https://github.com/bborgesr/room-manager)
View simple-server.js
const express = require("express");
const cors = require("cors");
const reservations = [
{
reservaID: 1,
usuarioID: 1,
salaID: 1,
data: "2020-01-31",
horaEntrada: "2020-01-31T10:00:00",
@bborgesr
bborgesr / to-do-list-vanilla-js.html
Created Dec 19, 2019
A very simple ToDo app using only vanilla JS
View to-do-list-vanilla-js.html
<html>
<head>
<title>Wonderful Task Manager</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
@bborgesr
bborgesr / hide-datatable-shiny.R
Created Mar 7, 2017
How to make a DataTable actually become hidden in a Shiny app
View hide-datatable-shiny.R
# -------------------------------------------------------------------
# ------------------ HIDIND A DATATABLE IN SHINY --------------------
# -------------------------------------------------------------------
# -------------------------------------------------------------------
# --- EXAMPLE 1: this sets the datatable's underlying dataframe to --
# --- NULL, inside a reactive (recalculated whenever a checkbox is --
# --- clicked). While this does result in the datatable disappearing
# --- from view, the height does not show ---------------------------
@bborgesr
bborgesr / checkbox-choiceNames-flags.R
Created Apr 4, 2017
Demo of new `checkboxGroupInput()` and `radioButtons()` functionality in Shiny 1.0.1
View checkbox-choiceNames-flags.R
library(shiny)
countries <- c("Australia", "United Kingdom", "United States")
flags <- c(
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/au.svg",
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/gb.svg",
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/us.svg"
)