Skip to content

Instantly share code, notes, and snippets.

View aagarw30's full-sized avatar

Abhinav Agrawal aagarw30

View GitHub Profile
@aagarw30
aagarw30 / app.R
Last active January 5, 2023 16:05
Upload zip folder and unzip it using R and Shiny
library(shiny)
ui <- fluidPage(
# Upload zip files
fileInput("file", "Upload Zip file", accept = ".zip"),
# action button to unzip the file
actionButton("unzip", "Unzip Files"),
# to display the metadata of the zipped file
tableOutput("filedf"),
@aagarw30
aagarw30 / server.r
Created March 11, 2018 17:58
3. R shinydashboard package - example - demo tabItems(), tabItem() - add tabs or pages corresponding to sidebar menu items in dashboardBody
library(shiny)
library(shinydashboard)
mydata = read.csv("Wholesale customers data.csv", stringsAsFactors = FALSE, header = TRUE)
shinyServer(function(input, output, session){
output$mydatatable <- renderDataTable({
mydata
})
@aagarw30
aagarw30 / server.r
Last active March 11, 2018 18:01
2. R shinydashboard package - example app - demo sidebarMenu(), menuItem() - add menu items to shinydashboard sidebar
library(shiny)
library(shinydashboard)
shinyServer(function(input, output, session){
}
)
@aagarw30
aagarw30 / server.r
Created March 11, 2018 11:46
2. shinydashboard package - example app - demo sidebarMenu(), menuItem() - add menu items to shinydashboard sidebar
library(shiny)
library(shinydashboard)
shinyServer(function(input, output, session){
}
)
@aagarw30
aagarw30 / server.r
Created March 11, 2018 11:12
1. Introduction to shinydashboard package - dashboardPage(), dashboardHeader(), dashboardSidebar(), dashboardBody()
library(shiny)
library(shinydashboard)
shinyServer(function(input, output, session){
}
)
@aagarw30
aagarw30 / server.r
Last active March 10, 2018 21:01
R Leaflet and Shiny - Example - Layers, Group and Layer Control along with markers
library(shiny) # load the shiny package
library(leaflet) # load the leaflet package
# quakes dataset is used for this app. It comes with base R.
# ?quakes in R console to read more about the dataset
# str(quakes)
# Classifying the type of earthquake based on magnitude as Light, Moderate, Strong or Major based on the magnitude range
quakes$type = ifelse((quakes$mag >= 4 & quakes$mag <= 4.9), "Light [4-4.9]",
ifelse((quakes$mag >= 5 & quakes$mag <= 5.9), "Moderate [5-5.9]",
@aagarw30
aagarw30 / app.R
Created February 12, 2018 06:13
Demo - side by side input widgets in R Shiny
library(shiny)
ui <- fluidPage(
tags$div(sliderInput("slide1", "Slider1", min = 0, max=10, value=4), style="display:inline-block"),
tags$div(sliderInput("slide1=2", "Slider2", min = 0, max=10, value=4), style="display:inline-block"),
tags$div(sliderInput("slide3", "Slider3", min = 0, max=10, value=4), style="display:inline-block")
)
@aagarw30
aagarw30 / server.r
Created February 1, 2018 07:09
navlistPanel w/o tabsetPanel - dataset showing
library(shiny)
shinyServer(function(input, output, session) {
output$table1 <- renderTable({
mtcars
})
output$summary1 <- renderText({
summary(mtcars)
})
@aagarw30
aagarw30 / server.r
Last active February 2, 2018 14:52
navlistPanel example with tasetPanel - dataset not showing up
library(shiny)
shinyServer(function(input, output, session) {
output$table1 <- renderTable({
mtcars
})
output$summary1 <- renderText({
summary(mtcars)
})
@aagarw30
aagarw30 / app.R
Last active February 1, 2018 05:45
Demo - Dynamic Widgets
library(shiny)
ui <- basicPage(
fluidRow(
selectInput("num", "select number of slider inputs", choices = seq(1,5,1)),
uiOutput("sliders"),
tableOutput("table"),
tableOutput("sum")
))