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 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 / 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 / server.r
Last active July 31, 2016 16:11
Plots2PDF
library(shiny)
shinyServer(function(input,output,session)({
# x contains all the observations of the x variable selected by the user. X is a reactive function
x <- reactive({
iris[,as.numeric(input$var1)]
})
# x contains all the observations of the y variable selected by the user. Y is a reactive function
y <- reactive({
iris[,as.numeric(input$var2)]
@aagarw30
aagarw30 / server.r
Created July 29, 2016 18:38
Tabsets and changing sidebarpanel widgets
library(shiny)
shinyServer(function(input,output)({
## Get the value of the dataset that is selected by user from the list of datasets
data <- reactive({
get(input$dataset)
})
## to output the dataset
@aagarw30
aagarw30 / server.r
Last active April 17, 2017 18:04
Download multi-plots in PDF
library(shiny)
library(ggplot2)
shinyServer(function(input,output)({
# downloadHandler contains 2 arguments as functions, namely filename, content
output$down <- downloadHandler(
filename = function() {
paste("multiplot.pdf")
},
@aagarw30
aagarw30 / server.r
Created July 27, 2016 14:53
Leaflet - map the data - reproducible
library(shiny)
library(leaflet)
library(RCurl)
shinyServer(function(input, output) {
URL <- getURL("https://commondatastorage.googleapis.com/ckannet-storage/2012-07-09T214020/global_airports.csv")
mydata <- read.csv(text = URL)
@aagarw30
aagarw30 / Places.R
Created July 26, 2016 19:09
Lat.Long
# install.packages("XML")
library(XML)
library(plyr)
# Preparing the data
cities <- c("Varanasi, India", "Jaipur, India", "Residency Road, Bangalore, India" ,"ITPL, Bangalore, India", "Phoenix, USA",
"Guadalajara, Mexico", "Marthahalli, Bangalore, India", "Melbourne, Australia","Bangalore, India")
desc = c("School @ St. John's School", "Graduation @ SKIT, Jaipur", "Job @ Think Ahead Advisory Services Ltd.",
"Job @ TCS Bang.", "Job @ TCS Phoenix", "Job @ TCS Mexico", "Job @ NICE Interactive Solutions", "Job @ NICE Systems Aus.","Job @ NICE Interactive Solutions")
# Function to get the latitude and longitude
@aagarw30
aagarw30 / server.r
Created July 12, 2016 04:14
fileInput R Shiny
library(shiny)
# use the below options code if you wish to increase the file input limit, in this example file input limit is increased from 5MB to 9MB
# options(shiny.maxRequestSize = 9*1024^2)
shinyServer(function(input,output){
# This reactive function will take the inputs from UI.R and use them for read.table() to read the data from the file. It returns the dataset in the form of a dataframe.
# file$datapath -> gives the path of the file
data <- reactive({
file1 <- input$file
@aagarw30
aagarw30 / DESCRIPTION
Last active May 22, 2016 19:18
SelectInput with options and actions
Title: Demo for multiple options and actions using selectinput
Description: Powered by R, Shiny and Rstudio.
License: GPL-3
Author: Abhinav Agrawal
DisplayMode: Showcase
Tags: R, R Shiny, shinydashboard
Type: Shiny
@aagarw30
aagarw30 / DESCRIPTION
Last active May 15, 2016 17:54
shinydashboard layout
Title: shinydashboard layout
Description: Powered by R, Shiny, shinydashboard and Rstudio.
License: GPL-3
Author: Abhinav Agrawal
DisplayMode: Showcase
Tags: R, R Shiny, shinydashboard
Type: Shiny