Skip to content

Instantly share code, notes, and snippets.

@ChrisBeeley
ChrisBeeley / dplyrReprex
Created November 13, 2018 16:29
This is just a reprex of a thing that I couldn't replicate on Stack Overflow https://stackoverflow.com/questions/34860535/how-to-use-dplyr-to-generate-a-frequency-table/34860724
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 3.4.4
#> -- Attaching packages ----------------------------------------------------------------------------------------------- tidyverse 1.2.1 --
#> v ggplot2 3.0.0 v purrr 0.2.4
#> v tibble 1.4.2 v dplyr 0.7.6
#> v tidyr 0.8.1 v stringr 1.3.0
#> v readr 1.1.1 v forcats 0.3.0
#> Warning: package 'ggplot2' was built under R version 3.4.4
#> Warning: package 'tibble' was built under R version 3.4.4
#> Warning: package 'readr' was built under R version 3.4.4
@ChrisBeeley
ChrisBeeley / app.R
Last active June 12, 2017 17:28
Single file app which takes various GET parameters and returns the appropriate date boxes (see below for link to blog post)
library(shiny)
library(lubridate)
server = function(input, output, session){
# type = date rolling n months, quarters
output$dateControls <- renderUI({
####################################
##### minimal example - server.R ###
####################################
library(shiny) # load shiny at beginning at both scripts
shinyServer(function(input, output) { # server is defined within these parentheses
output$textDisplay <- renderText({ # mark function as reactive and assign to
# output$textDisplay for passing to ui.R
@ChrisBeeley
ChrisBeeley / server.R
Last active August 29, 2015 14:26
Minimal application for Shiny Book, 2nd edition
library(shiny) # load Shiny at the top of both scripts
shinyServer(function(input, output) { # define application in here
output$textDisplay <- renderText({ # mark function as reactive
# and assign to output$textDisplay for passing to ui.R
paste0("You said '", input$comment, # from the text
"'. There are ", nchar(input$comment), # input control as
" characters in this.") # defined in ui.R