Skip to content

Instantly share code, notes, and snippets.

@stla
stla / global.R
Created November 6, 2013 10:51
Shiny: dynamic number of tabs and tab-dependent UI in the sidebar
## generates two datasets for illustration
I <- 3 # nb tests
J <- 4 # nb timepoints
dat1 <- data.frame(
Test=gl(I,J,labels=LETTERS[1:I]),
timepoint=rep(1:J,I)
)
dat1 <- transform(dat1, y=round(rnorm(I*J,2*timepoint),1))
I <- 5 # nb tests
J <- 3 # nb timepoints
@stla
stla / global.R
Last active December 28, 2015 04:09
Shiny: dynamic number of tabs and tab-dependent UI in the sidebar - v2
# generates a html link at topright position
sourcecode <- function(link){
tags$a(href=link,
style="float:right; padding-right:10px;padding-top:10px; color:yellow; background-color:red; font-family:arial; font-size:20px",
">>source code<<")
}
## generates two datasets for illustration
#
tests <- c("aaa","bbb","ccc")
@stla
stla / global.R
Last active December 28, 2015 06:29
Shiny: two methods for tab-dependent widgets with dynamic number of tabs
# generates a html link at topright position
sourcecode <- function(link){
tags$a(href=link,
style="float:right; padding-right:10px;padding-top:10px; color:yellow; background-color:red; font-family:arial; font-size:20px",
">>source code<<")
}
## generates two datasets for illustration
#
tests <- c("aaa","bbb","ccc")
@stla
stla / widget_colorSelector.R
Last active December 30, 2015 20:39
Color selector widget with gWidgets2RGtk2
library(gWidgets2RGtk2)
library(cairoDevice)
library(ggplot2)
### make two examples datasets ###
dat1 <- data.frame(FACTOR1=gl(2,3, labels=c("abc","ABC")), FACTOR2=gl(3,2, labels=c("uv","wx","yz")), x=1:6, y=1:6)
dat2 <- data.frame(FACTOR1=gl(2,3, labels=c("xyz","XYZ")), FACTOR2=gl(3,2, labels=c("ab","cd","ef")), x=1:6, y=6:1)
### gWidgets macros ###
@stla
stla / animateImage.html
Created February 14, 2014 19:17
my first jQuery test
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function()
{
$("#btn1").click(function(){
$("#box").animate({width:"300px"});
@stla
stla / ShinyColumnsSelector.R
Last active August 29, 2015 13:56
Shiiny: two selectInput with mutual exclusion
library(shiny)
runApp(
list(ui=pageWithSidebar(
headerPanel("Column Selector - first idea"),
sidebarPanel(
uiOutput("dyncolumns")
),
mainPanel(
tableOutput("subset"),
@stla
stla / JLF.html
Last active August 29, 2015 13:56
Jean-Luc
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function()
{
$("#btn1").click(function(){
$("#box").animate({width:"200px"});
@stla
stla / server.R
Created May 10, 2014 20:30 — forked from withr/server.R
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
output$caption <- renderText({
@stla
stla / kantorovich_v00.scala
Created June 9, 2014 15:40
kantorovich with scala - v00
import breeze.optimize.linear._
object Main {
def main(args: Array[String]) {
println("\nWelcome.\nOpen the console and type e.g. new kantorovich(Array(1.0/7, 2.0/7, 4.0/7), Array(1.0/4, 1.0/4, 1.0/2)).run()\n")
}
}
@stla
stla / RgfiJgfi01.html
Created July 13, 2014 19:02
Comparison Rgfi/Jgfi - 01
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />