This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data { | |
| int jj_n; | |
| int jj_idx[jj_n]; | |
| int jj_groups[jj_n]; | |
| ... | |
| } | |
| parameters { | |
| vector[3] beta; | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foo <- structure(rnorm(100), class = "test") | |
| t(foo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| install.packages(c("ggplot2", "devtools", "shiny")) | |
| library(devtools) | |
| install_github("jrnold/pols_math_camp_2014") | |
| library(mathcamp) | |
| run_shiny_example("functions") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("shiny") | |
| x <- seq(-4, 4, by=0.01) | |
| norm_dens <- dnorm(x) | |
| shinyServer(function(input, output) { | |
| output$plot <- renderPlot({ | |
| t_dens <- dt(x, df = input$df) | |
| print(ggplot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("shiny") | |
| library("ggplot2") | |
| library("plyr") | |
| norm_mean <- 0 | |
| norm_sd <- 1 | |
| ##' Take sample from normal dist and calculate confidence interval for normal | |
| smpl_mean_sample_ci <- function(n, p=0.95, pop_mean=0, pop_sd=1) { | |
| smpl <- rnorm(n, norm_mean, norm_sd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Copyright: Martin Berlin, Jeffrey Arnold <jeffrey.arnold@gmail.com> (2013) | |
| ## | |
| ## Adapted from original code by Martin Berlin <mno.berlin@gmail.com> http://spark.rstudio.com/berlin/stat/ | |
| library(shiny) | |
| library(plyr) | |
| library(ggplot2) | |
| ## Generate data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("ggplot2") | |
| #' Draw Normal Distribution Density with an area shaded in. | |
| #' | |
| #' @param lb Lower bound of the shaded area. Use \code{-Inf} for a left tail. | |
| #' @param ub Upper bound of the shaded area. Use \code{Inf} for a right tail. | |
| #' @param mean Mean of the normal distribution | |
| #' @param sd Standard deviation of the normal distribution | |
| #' @param limits Lower and upper bounds on the x-axis of the area displayed. | |
| #' @return ggplot object. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| quantile.ordered <- function(x, probs = seq(0, 1, 0.25)) { | |
| tab <- table(x) | |
| cdf <- cumsum(tab / sum(tab)) | |
| idx <- sapply(probs, function(p) min(which(cdf >= p))) | |
| levels(x)[idx] | |
| } | |
| quantile.factor <- quantile.ordinal | |
| median.ordered <- function(x) quantile(x, 0.5) | |
| median.factor <- median.ordered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("stringr") | |
| library("ggplot2") | |
| shinyServer(function(input, output) { | |
| output$main_plot <- | |
| renderPlot({ | |
| x <- as.numeric(str_split(input$data, ",")[[1]]) | |
| xseq <- seq(min(x), max(x), length.out=100) | |
| xvar <- var(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data { | |
| int n; | |
| int m; | |
| row_vector[m] alpha; | |
| } | |
| parameters { | |
| row_vector[m] beta[n-1]; | |
| } | |
| transformed parameters { | |
| matrix[n, m] alpha_beta; |