Skip to content

Instantly share code, notes, and snippets.

<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css'>
<script src='http://code.jquery.com/jquery-1.10.2.min.js' type='text/javascript'></script>
<script src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js' type='text/javascript'></script>
<style>
@stla
stla / server.R
Created September 12, 2013 11:56
Series of tabs with Shiny - test 1
mytabsetPanel <- function (tabs, id = NULL, selected = NULL)
{
#tabs <- list(...)
tabNavList <- tags$ul(class = "nav nav-tabs", id = id)
tabContent <- tags$div(class = "tab-content")
firstTab <- TRUE
tabsetId <- as.integer(stats::runif(1, 1, 10000))
tabId <- 1
for (divTag in tabs) {
thisId <- paste("tab", tabsetId, tabId, sep = "-")
@stla
stla / global.R
Created September 12, 2013 15:56
Series of tabs with Shiny - test4
mytabsetPanel <- function (tabs, id = NULL, selected = NULL)
{
#tabs <- list(...)
tabNavList <- tags$ul(class = "nav nav-tabs", id = id)
tabContent <- tags$div(class = "tab-content")
firstTab <- TRUE
tabsetId <- as.integer(stats::runif(1, 1, 10000))
tabId <- 1
for (divTag in tabs) {
thisId <- paste("tab", tabsetId, tabId, sep = "-")
@stla
stla / global.R
Created September 12, 2013 20:14
Series of tabs with Shiny - test 5
## slight modification of tabsetPanel() function
mytabsetPanel <- function (tabs, id = NULL, selected = NULL)
{
#tabs <- list(...)
tabNavList <- tags$ul(class = "nav nav-tabs", id = id)
tabContent <- tags$div(class = "tab-content")
firstTab <- TRUE
tabsetId <- as.integer(stats::runif(1, 1, 10000))
tabId <- 1
for (divTag in tabs) {
@stla
stla / global.R
Created September 13, 2013 11:26
Series of tabs with Shiny - test 7
## 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 / main.Rmd
Last active December 24, 2015 06:09
Inline R code in a child file recursively called - See output at http://pagist.github.io/?6755031
Define `x`:
```{r}
x <- LETTERS[1:5]
i <- 1
```
```{r child, child="sub.Rmd"}
```
@stla
stla / main.html
Created September 29, 2013 18:11
Inline R code in a child file recursively called: output html file
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
body, td {
@stla
stla / global.R
Created October 22, 2013 22:23
test datatables shiny_v8 and rCharts
# test whether rCharts is installed
rcharts <- require(rCharts)
# test shiny version
shinyv8 <- packageVersion("shiny") == '0.7.0.99'
# auxiliary function to extract numbers from a character string
numextract <- function(string){ # http://stackoverflow.com/questions/19252663/extracting-decimal-numbers-from-a-string
str_extract(string, "\\d+\\.*\\d*")
}
@stla
stla / SessionInfo.Rmd
Last active December 26, 2015 11:39
Shiny Session Report - v0
```{r sessionInfo, echo=FALSE}
si <- sessionInfo()
opkgver <- sapply(si$otherPkgs, function(x) x$Version)
nspkgver <- sapply(si$loadedOnly, function(x) x$Version)
opkgver <- opkgver[sort(names(opkgver))]
nspkgver <- nspkgver[sort(names(nspkgver))]
verso <- paste("(v", opkgver, ")", sep = "")
versns <- paste("(v", nspkgver, ")", sep = "")
```
@stla
stla / global.R
Last active December 26, 2015 17:19
Shiny ImageMagick - single file
library(shiny)
library(shinyIncubator)
library(shinyAce)
options(shiny.maxRequestSize = -1)
platform <- sessionInfo()$R.version$platform
linux <- stringr::str_detect(platform, "linux")
logo <- function(img,link, height="200px") tags$a(href=link, tags$img(src=img, height=height))
sourcecode <- function(link){