Skip to content

Instantly share code, notes, and snippets.

View dkulp2's full-sized avatar

David Kulp dkulp2

View GitHub Profile
@dkulp2
dkulp2 / opex.R
Last active February 10, 2016 15:17
Rough calculations of opex for groups of towns
library(dplyr)
library(ggplot2)
fiber.plant.depreciation <- 1395 # per mile
insurance <- 442 # per mile
bond.fees <- 3 # per pole
pole.rental <- 13 # per pole
electronics.depreciation <- 63 # per premise
routine.mtnce <- 39 # per premise
network.operator.base <- 16800 # per town(!)
@dkulp2
dkulp2 / app.R
Created October 16, 2017 03:14
Deferred UI breaks Shiny app
# example Shiny app where uiOutput is only rendered when panel is selected, but other
# items are dependent on the deferred UI.
library(shiny)
ui <- fluidPage(
tabsetPanel(tabPanel("Main",
plotOutput("dots")),
tabPanel("Settings",
# checkboxInput('even','Even?',TRUE)
@dkulp2
dkulp2 / app.R
Last active October 16, 2017 18:23
Sticky rows in DT table
library(shiny)
ui <- fluidPage(
checkboxInput('yellow.only', 'Yellow Only'),
uiOutput('fruit.selection'),
DT::dataTableOutput("dt.fruit.selection")
)
server <- function(input, output) {
Verifying my Blockstack ID is secured with the address 1B4SvJwaiFR131mvTFNCUoB1HWJKYRzYHy https://explorer.blockstack.org/address/1B4SvJwaiFR131mvTFNCUoB1HWJKYRzYHy
@dkulp2
dkulp2 / app.R
Created October 26, 2018 18:30
Slow shinyalert with large memory and callback
library(shiny)
library(shinyalert)
options(digits.secs=6)
ui <- fluidPage(
useShinyalert(),
@dkulp2
dkulp2 / app.R
Created December 27, 2018 05:56
Example shiny dynamic download
# Author: dkulp2
#
# Shiny example for dynamically downloading a file related to a specific row.
#
# A DT datatable is created with options that adds a 'download-control' class to a column with a download icon
# and a callback to set up the click event on the 'download-control' cells.
# The javascript click event determines which page of the datatable is being displayed and which row the click event occurred.
# This approach fails if rows are reordered or the table is filtered, so both are disabled. An alternative is to place the
# row ID in a "data-" attribute, which would allow reordering and filtering.
# It then sends a Shiny event, 'download-row', with the index of the row in the table.
stat_smooth_func <- function(mapping = NULL, data = NULL,
geom = "smooth", position = "identity",
...,
method = "auto",
formula = y ~ x,
se = TRUE,
n = 80,
span = 0.75,
fullrange = FALSE,
level = 0.95,