Skip to content

Instantly share code, notes, and snippets.

View haozhu233's full-sized avatar
🧙

Hao Zhu haozhu233

🧙
View GitHub Profile
@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 %>%
@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 / 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 / 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 / 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 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))