Skip to content

Instantly share code, notes, and snippets.

View jcheng5's full-sized avatar

Joe Cheng jcheng5

View GitHub Profile
@jcheng5
jcheng5 / global.R
Last active November 30, 2022 02:01 — forked from dgrapov/global.R
#initialize
library(datasets)
library(ggplot2)
#helper function (convert vector to named list)
namel<-function (vec){
tmp<-as.list(vec)
names(tmp)<-as.character(unlist(vec))
tmp
}
@jcheng5
jcheng5 / global.R
Last active December 20, 2021 14:32 — forked from dempseydata/global.R
###############################################
##
## Attempt no 2 at building a shiny web app
## for AB Testing use - using global.R
##
## global.R - loading and defining variables for the global environment
##
###############################################
# Pallette used in some charts as a general indicator color for better or worse that the control group
@jcheng5
jcheng5 / server.r
Created October 29, 2012 06:21 — forked from wch/server.r
Experiments with shiny and ggplot2
library(shiny)
library(datasets)
library(ggplot2)
tg <- ToothGrowth
tg$dose <- factor(tg$dose)
# Define server logic
shinyServer(function(input, output) {
@jcheng5
jcheng5 / server.R
Last active April 17, 2018 01:32 — forked from Athospd/server.R
library(shiny)
library(magrittr)
shinyServer(function(input, output, session) {
#__________________________________________________________________________________
# The main named list that will be used in many other tasks.
listN <- reactiveValues()
makeReactiveBinding("listN")
@jcheng5
jcheng5 / app.R
Created May 26, 2016 16:45 — forked from charlesmilk/app.R
Shiny - The grey bar is not follow the size of the plots bigger than the window size
library(shiny)
library(shinyjs)
library(DT)
data("cars")
ui <- tagList(
useShinyjs(),
navbarPage("OSD",
@jcheng5
jcheng5 / app1.R
Last active February 25, 2016 16:18 — forked from Vestaxis/app1.R
Three Shiny apps that export UI components to a separate Shiny module.
# Simple example of exporting UI to another function (this works)
library(shiny)
tabUI <- function(id) {
ns <- NS(id)
fluidRow(
textOutput(ns("filter"))
)
}
library(shiny)
library(datasets)
shinyServer(function(input, output) {
## Inputs;
output$uitextInput <- renderUI({
textInput("caption", "Caption:", "Data Summary")
})
@jcheng5
jcheng5 / server.R
Created August 14, 2013 06:53 — forked from tcash21/server.R
require(shiny)
require(rCharts)
inputChoices <- c("A", "B", "C", "D")
shinyServer(function(input, output, session){
input2Choices <- reactive({
inputChoices[-grep(input$input1, inputChoices)]
})
@jcheng5
jcheng5 / Global.R
Last active December 16, 2015 09:58 — forked from OliverBears/Global.R
library(chron)
library(shiny)
energy1=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5)
cost1=c(7.1,7,7.1,7.2,7.8,7.7,7.9,8.1,8.2,8.8,8.8,8.5)
time1=c(20130301,20130401,20130501,20130601,20130701,20130801,20130901,20131001,20131101,20131201,20140101,20140201)
time1=as.Date(as.character(time1),format="%Y%m%d")
shinymonth=data.frame(time=time1,energy=energy1,cost=cost1)
#StrategicPestTechnologies: Functions
#~~~~~~~~~~~Calc trap info~~~~~~~~~~~~
trap.info.func<-function(file){
#Take file
#Return: traps, n.traps, ylims, xlims, total.area
traps<-read.table(file, header=FALSE)
colnames(traps)<-c("ID","X","Y")
n.traps<-dim(traps)[1]