Skip to content

Instantly share code, notes, and snippets.

View ptoche's full-sized avatar
💭
fooling around

Patrick Toche ptoche

💭
fooling around
  • strange indentations
  • I live in Hong Kong in the U.S. time zone, but my heart is still in Europe.
View GitHub Profile
@ptoche
ptoche / server.R
Created January 7, 2014 16:47 — forked from jknowles/server.R
# Script to demonstrate distributions
library(VGAM)
library(eeptools)
library(shiny)
library(ggplot2)
shinyServer(function(input,output){
@ptoche
ptoche / server.R
Last active January 2, 2016 12:19 — forked from jknowles/server.R
# server.R
library("shiny")
library("ggplot2") # Grammar of Graphics for plots
library("VGAM") # Vector Generalized Linear and Additive Models
library("eeptools") # Convenience functions for education data
shinyServer(
function(input,output){
@ptoche
ptoche / server.R
Last active January 2, 2016 12:29 — forked from jknowles/server.R
# server.R
library("shiny")
library("ggplot2") # Grammar of Graphics for plots
library("eeptools") # Convenience functions for education data
# static function
rnormcor <- function(x,rho) {rnorm(1,rho*x,sqrt(1-rho^2))}
shinyServer(
@ptoche
ptoche / server.R
Last active January 2, 2016 12:29 — forked from jknowles/server.R
# server.R
library("shiny")
library("ggplot2") # Grammar of Graphics for plots
library("eeptools") # Convenience functions for education data
library("plyr") # Convenience functions to manipulate data
shinyServer(
function(input,output){
# global.R
c1 <- c("16681","16892","18586","18921","18923","19731","19775","20275","20965","22873")
c2 <- c("20267","24093","24095","25386","25359","25388","25396","25397")
@ptoche
ptoche / server.R
Last active January 2, 2016 13:59
minor edits to the very awesome app seen here: https://gist.github.com/jcheng5/3971908
# server.R
library("shiny")
library("datasets")
library("ggplot2")
tg <- ToothGrowth
tg$dose <- factor(tg$dose)
shinyServer(function(input, output) {
@ptoche
ptoche / server.R
Created January 9, 2014 17:02
Bug Watch: sliderInput displays wrong value. Problem seems to occur for large values (k but not n). Not tested extensively. Bug reported. # ui.R sliderInput("k", "k:", value = 1000, min = 2, max = 10000) # server.R paste0("input$k = ",input$k) result: input$k = 1002 on start or refresh, instead of the assigned 1000.
library("shiny")
shinyServer(
function(input, output, session) {
output$text_n <- renderText({
paste0("input$n = ",input$n)
})
output$text_k <- renderText({
@ptoche
ptoche / global.R
Created January 11, 2014 21:07
BROKEN - NEW VERSION IN PROGRESS. ................................................. - users input a function of several variables, select one unknown and several parameter values, the app produces a customizable plot. This is a first version. Also experimental is the layout, based on several panels: they don't always look good, depending on zoom…
# global.R
# Author: Patrick Toche, first version 12 January 2014
# I am very grateful for generous help received on stackoverflow and on the shiny-discuss forum
# Please fix, improve, fork, share, whatever...
# gArg = default arguments
# gFun = default function
# Static Parameters
@ptoche
ptoche / server.R
Last active January 3, 2016 00:49
Demo on matrixInput from package shinyIncubator
# server.R
library("shiny")
library("shinyIncubator")
shinyServer(
function(input, output) {
# table of outputs
output$table <- renderTable({
res <- matrix(apply(input$data,1,prod))
@ptoche
ptoche / global.R
Created January 12, 2014 16:10
Demo on 'source' tags$style from global.R, alternative to includeCSS("www/style.css")
# global.R
# customize display settings here
gTags <- function() {
tags$head(
tags$style(
type = 'text/css'
, "body {font-size: 80%; color: rgb(0,0,100);}"
, "#mainPanelId {min-width: 50%; max-width: 70%; float: right;}"
, "#sidebarPanelId {min-width: 10%; max-width: 20%; float: left;}"