Skip to content

Instantly share code, notes, and snippets.

View haozhu233's full-sized avatar
🧙

Hao Zhu haozhu233

🧙
View GitHub Profile
@haozhu233
haozhu233 / server.r
Created September 28, 2015 19:56
reproducible bug case for ggvis
library(dplyr)
library(ggvis)
library(shiny)
shinyServer(function(input, output, session) {
session$onSessionEnded(function() {
stopApp()
})
mtcars$cyl <- factor(mtcars$cyl, levels = c(4L,6L, 8L))
@haozhu233
haozhu233 / server.r
Created September 30, 2015 17:31
Add back/next button to date range input in shiny
library(shiny)
shinyServer(function(input, output, session) {
session$onSessionEnded(function() {
stopApp()
})
date.range <- as.Date(c("2015-01-01", "2015-12-31"))
# ------- Date Range Input + previous/next week buttons---------------
output$choose.date <- renderUI({
@haozhu233
haozhu233 / server.r
Created October 4, 2015 06:56
a question on so
library(shiny)
shinyServer(
function(input, output) {
x <- data.frame(PRODUCT=factor(c("ALPHA", "ALPHA","BRAVO","ALPHA","ALPHA")),
YYYYMM= factor(c("2/1/2015","3/1/2015","4/1/2015","5/1/2015","6/1/2015")),
COUNT=c(44,22,37,76,97))
## select only rows where PRODUCT = input$product
x1 <- reactive({
@haozhu233
haozhu233 / app.R
Created January 9, 2017 16:23
Shiny - Create A Table whose cells can be toggled on and off with clicks
library(shiny)
library(ggplot2)
library(dplyr)
server <- function(input, output, session){
weekdays <- c("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday")
rv <- reactiveValues(
dt = data.frame(
@haozhu233
haozhu233 / app.R
Last active July 3, 2024 15:35
Use kable in Shiny
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("mtcars"),
sidebarLayout(
sidebarPanel(
sliderInput("mpg", "mpg Limit",
@haozhu233
haozhu233 / demo.Rmd
Created November 10, 2017 21:39
2 tables in the same row
---
output: html_document
---
```{r}
library(tidyverse)
library(kableExtra)
library(knitr)
a <- mpg %>%
library(shiny)
library(imager)
library(colocr)
# Define UI for application that draws a histogram
ui <- navbarPage(
title = 'colocr',
tabPanel(
'Main',
sidebarLayout(
@haozhu233
haozhu233 / grouped_forest.R
Last active September 27, 2018 19:45
forest plot with grouping need
library(broom)
library(tidyverse)
library(viridis)
fit <- lm(mpg ~ ., data = mtcars)
fit_dt <- tidy(fit, conf.int = T)
# reverse the order so it looks right on plot
@haozhu233
haozhu233 / bs-table.css
Created May 10, 2019 20:11
bootstrap 3 table part
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*!
* Generated using the Bootstrap Customizer (<none>)
* Config saved to config.json and <none>
@haozhu233
haozhu233 / demo.Rmd
Created July 10, 2019 04:56
linebreak + %
---
title: "Untitled"
author: "Hao"
date: "7/10/2019"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```