Skip to content

Instantly share code, notes, and snippets.

@MayaGans
MayaGans / app.R
Last active July 27, 2021 18:18
module NS
library(shiny)
# function to make inputs
shinyInput <- function(FUN, len, id, ...) {
inputs <- character(len)
for (i in seq_len(len)) {
inputs[i] <- as.character(FUN(paste0(id, i), ...))
}
inputs
/*
Copyright (c) 2013-2020 NDP Software, Andrew J. Peterson
* https://github.com/ndp/align-column
*/
$.fn.alignColumn = function (columns, options) {
var config = $.extend({}, {
addedCellClass: 'added',
skipTHs: true
/*
Copyright (c) 2013-2020 NDP Software, Andrew J. Peterson
* https://github.com/ndp/align-column
*/
$.fn.alignColumn = function (columns, options) {
var config = $.extend({}, {
addedCellClass: 'added',
skipTHs: true
@MayaGans
MayaGans / app.R
Last active June 4, 2021 17:36
move page number to bottom of table
library(shiny)
library(DT)
library(purrr)
# the dataframe contains a column
# of unique vectors for each row
dummy <- tibble::tibble(
a = letters[1:3],
b = 1:3,
@MayaGans
MayaGans / app.R
Created May 25, 2021 14:45
Select rows from a table for downloading
library(shiny)
library(DT)
data <- data.frame(
a = 1:10,
b = 1:10
)
ui <- fluidPage(
@MayaGans
MayaGans / app.R
Last active May 21, 2021 15:20
Full Screen Button
library(shiny)
ui <- fluidPage(
# I cant add folders in a gis but script and css need to be in www for this to work!
addResourcePath("www", system.file('app/www')),
div(
div(id = "demo", style="position:relative;",
actionButton("full_screen", icon('expand', class = NULL, lib = "font-awesome")),
DT::dataTableOutput("demo_table")
)
@MayaGans
MayaGans / app.R
Created May 20, 2021 16:33
awesomeCheckbox Alignment
# checkbox color and alignment
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$head(tags$style(HTML('
.checkbox-primary input[type="checkbox"]:checked+label::before, .checkbox-primary input[type="radio"]:checked+label::before {
background-color: red;
border-color: red;
}
@MayaGans
MayaGans / app.R
Created May 19, 2021 14:25
Hacking Bookmarking
library(shiny)
# stealing this from the shiny source code for updateXInput
dropNulls <- function(x) {
x[!vapply(x, is.null, FUN.VALUE=logical(1))]
}
ui <- function() {
tagList(
sliderInput("test1", "Slider", value = 2, min = -2, max = 2, step = 0.01),
@MayaGans
MayaGans / Day7.R
Last active April 7, 2021 21:23
Day 7: Physical
library(dplyr)
library(ggplot2)
df <- data.frame(
x = rep(c(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), 6),
y = rep(c(1, 2, 3, 4, 5), each = 12),
z = 1:60,
w = rep(diff(c(0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20)), 6),
values = c(
"NA", "NA", "white", "red", "white",
@MayaGans
MayaGans / app.R
Created January 11, 2021 15:38
nested renderUI?
library(shiny)
ui <- fluidPage(
numericInput("n_questions", "Number of Questions", value = 1, min = 1),
# basically we should get input$n_questions number of these wellpanels
# so this entire thing needs to be a function
# but where my brain starts hurting is that the number of choices
# is going to dictate the number of text fields
# for EACH of these well panels