This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load required packages | |
library(shiny) | |
library(ggplot2) | |
library(dplyr) | |
# Adding State column to the original dataset for easy data manipulation at a later stage | |
states = row.names(USArrests) | |
crimedata = USArrests %>% | |
mutate("State" = as.factor(states)) # convert State to a factor variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
ui <- fluidPage( | |
radioButtons(inputId = "plot_type" , label = "Select the plot", choices = c("scatter", "bar", "hist" )), | |
plotOutput("myplot") | |
) | |
server <- function(input, output, session) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## How to disable the plotly tool bar from right top corner | |
## We will be using the pressure dataset for sake of demo | |
## Single file shiny app | |
## install the packages if not already | |
## Load the required libraries | |
library(shiny) # for shiny functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
# options(shiny.trace=T) | |
shinyServer(function(input,output) { | |
## input$file is a data frame and contains the details around the name, size and temp location of the files uploaded | |
# this reactive output display the content of the input$file dataframe | |
output$filedf <- renderTable({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load required packages | |
library(shiny) | |
library(ggplot2) | |
# UI Code begins here | |
ui <- fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
## Add inputs widgets later | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(leaflet) | |
library(dplyr) | |
# Create a small dataframe | |
visits = data.frame(City=c("Bangalore", "Delhi", "Chennai", "Bangalore"), | |
lat=c(12.972442, 28.644800, 13.067439, 12.972442), | |
lon=c(77.580643, 77.216721, 80.237617, 77.580643), | |
Year=c("2007", "2008", "2009", "2010")) | |
visits$Year = as.Date(visits$Year, format="%Y") |
NewerOlder