Skip to content

Instantly share code, notes, and snippets.

View aagarw30's full-sized avatar

Abhinav Agrawal aagarw30

View GitHub Profile
@aagarw30
aagarw30 / DESCRIPTION
Last active February 20, 2024 16:42
Use case - Change the side bar panel elements based on the selected tab
Title: Use case - Change the side bar panel elements based on the selected tab & demo conditionalPanel() function
Description: Powered by R, Shiny, GGPLOT2 and RStudio.
License: GPL-3
Author: Abhinav Agrawal
DisplayMode: Showcase
Tags: R, R Shiny,TabsetPanel, ConditionalPanel
Type: Shiny
@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 / eventdata.R
Created April 1, 2020 08:00
Interactive data point selection with ggplotly/plotly charts
## Load required packages
library(plotly)
library(ggplot2)
library(shiny)
## Defining a key column in mtcars which will be used for event handling in event_data()
mtcars$key <- row.names(mtcars)
@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 / ggcorrplot.R
Created March 14, 2022 18:57
R Tutorial - Visualization of correlation matrix in R using ggcorrplot package in R - ggcorrplot tutorial - ggplot2 extension
# Demonstration of ggcorrplot package
# Package created by Alboukadel Kassambara
# Reference link - https://cran.r-project.org/web/packages/ggcorrplot/ggcorrplot.pdf
# Load the required libraries
# install.packages("ggcorrplot")
library(ggcorrplot)
# mtcars dataset from base R used here for demonstration
@aagarw30
aagarw30 / DESCRIPTION
Last active July 24, 2022 15:53
Demo updateselectInput() and also introducing observeEvent() function
Title: Use case - Demo updateselectInput() and also introducing observeEvent() function
Description: Powered by R, Shiny, and RStudio.
License: GPL-3
Author: Abhinav Agrawal
DisplayMode: Showcase
Tags: R, R Shiny,updateselectInput(), observeEvent()
Type: Shiny
@aagarw30
aagarw30 / Rplotlytutorial.r
Last active May 14, 2022 01:07
R Plotly Tutorial - Code Snippets
#### Brief introduction to R Plotly package ####
# The plotly package in R is an interface to open source Javascript charting library plotly.js
# Plots can be created online in the plotly web GUI or offline using the plotly package
# Interactive plots that can be easily shared online using the plotly API/account
# Plotly plots can embed into R Markdown, R Shiny
# Tool tip feature and other controls
# ggplot2 graphs can be easily converted to interactive plotly objects using ggplotly() function
# Package documentation
# https://cran.r-project.org/web/packages/plotly/plotly.pdf
@aagarw30
aagarw30 / App.R
Last active April 13, 2022 14:16
Choose plots and display using radio button
library(shiny)
ui <- fluidPage(
radioButtons(inputId = "plot_type" , label = "Select the plot", choices = c("scatter", "bar", "hist" )),
plotOutput("myplot")
)
server <- function(input, output, session) {
@aagarw30
aagarw30 / App.R
Created April 7, 2022 03:34
Demo example for reactiveVal() with observeEvent() - Create dependency on actionButton - Subset data on click of actionButton and display in datatable
# Demo example for reactiveVal with observeEvent()
# Create dependency on a button to reflect user input changes to the rendered output
library(shiny) # for Shiny components
library(dplyr) # for piping
my = mtcars %>%
mutate(cyl = as.factor(cyl))
ui <- fluidPage(
h4("Demo of using reactiveVal() along with observeEvent() in R Shiny to subset data and display on click of action Button"),
@aagarw30
aagarw30 / action1.R
Last active April 5, 2022 19:05
Demo eventReactive() - subset data on click of button and display the resultant data
# Demo example for eventReactive()
# Create dependency on a button to reflect user input changes to the rendered output
# subset data on click of button and display the resultant data
# Load the required libraries
library(shiny) # for Shiny components
library(dplyr) # for piping and data manipulation
# For demo using the mtcars dataset
# convert the cylinder variable to factor type