-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed 8d6c450 with MkDocs version: 1.6.0
- Loading branch information
0 parents
commit 1f0b90f
Showing
337 changed files
with
84,410 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
library(shiny) | ||
|
||
# Define UI | ||
ui <- fluidPage( | ||
titlePanel(""), | ||
|
||
sidebarLayout( | ||
sidebarPanel( | ||
# input here | ||
# check: https://shiny.posit.co/r/gallery/widgets/widget-gallery/ | ||
), | ||
|
||
mainPanel( | ||
# output here | ||
# check: https://github.com/rstudio/cheatsheets/blob/main/shiny.pdf | ||
) | ||
) | ||
) | ||
|
||
# Define server logic | ||
server <- function(input, output) { | ||
|
||
output$result <- renderText({ | ||
num1 <- 2 | ||
num2 <- 1 | ||
|
||
result <- switch(input$operation, | ||
"add" = num1 + num2, | ||
"subtract" = num1 - num2, | ||
"multiply" = num1 * num2, | ||
"divide" = num1 / num2 | ||
) | ||
|
||
paste("Result:", result) | ||
}) | ||
} | ||
|
||
# Run the application | ||
shinyApp(ui = ui, server = server) |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
library(shiny) | ||
library(reactlog) | ||
|
||
reactlog_enable() | ||
|
||
ui <- function() { | ||
|
||
# k-means only works with numerical variables, | ||
# so don't give the user the option to select | ||
# a categorical variable | ||
vars <- setdiff(names(iris), "Species") | ||
|
||
pageWithSidebar( | ||
headerPanel('Iris k-means clustering'), | ||
sidebarPanel( | ||
selectInput('xcol', 'X Variable', vars), | ||
selectInput('ycol', 'Y Variable', vars, selected = vars[[2]]), | ||
numericInput('clusters', 'Cluster count', 3, min = 1, max = 9) | ||
), | ||
mainPanel( | ||
plotOutput('plot1') | ||
) | ||
)} | ||
|
||
|
||
|
||
|
||
server <- function(input, output, session) { | ||
|
||
# Combine the selected variables into a new data frame | ||
selectedData <- reactive({ | ||
iris[, c(input$xcol, input$ycol)] | ||
}) | ||
|
||
clusters <- reactive({ | ||
kmeans(selectedData(), input$clusters) | ||
}) | ||
|
||
output$plot1 <- renderPlot({ | ||
palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", | ||
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999")) | ||
|
||
par(mar = c(5.1, 4.1, 0, 1)) | ||
plot(selectedData(), | ||
col = clusters()$cluster, | ||
pch = 20, cex = 3) | ||
points(clusters()$centers, pch = 4, cex = 4, lwd = 4) | ||
}) | ||
|
||
} | ||
|
||
shinyApp(ui = ui, server = server) | ||
|
||
shiny::reactlogShow() | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
library(shiny) | ||
|
||
# Define UI | ||
ui <- fluidPage( | ||
titlePanel("Shiny Calculator"), | ||
|
||
sidebarLayout( | ||
sidebarPanel( | ||
numericInput("num1", label = "Enter first number:", value = 0), | ||
numericInput("num2", label = "Enter second number:", value = 0), | ||
radioButtons("operation", label = "Choose operation:", choices = list( | ||
"add", | ||
"subtract", | ||
"multiply", | ||
"divide" | ||
)) | ||
), | ||
|
||
mainPanel( | ||
textOutput("result") | ||
) | ||
) | ||
) | ||
|
||
# Define server logic | ||
server <- function(input, output) { | ||
|
||
output$result <- renderText({ | ||
if (input$operation == "divide") { | ||
req(input$num2 != 0) | ||
} | ||
|
||
result <- switch(input$operation, | ||
"add" = input$num1 + input$num2, | ||
"subtract" = input$num1 - input$num2, | ||
"multiply" = input$num1 * input$num2, | ||
"divide" = input$num1 / input$num2 | ||
) | ||
|
||
paste("Result:", result) | ||
}) | ||
|
||
} | ||
|
||
# Run the application | ||
shinyApp(ui = ui, server = server) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
library(shiny) | ||
|
||
# Define UI | ||
ui <- fluidPage( | ||
titlePanel("Shiny Calculator"), | ||
|
||
sidebarLayout( | ||
sidebarPanel( | ||
numericInput("num1", label = "Enter first number:", value = 0), | ||
numericInput("num2", label = "Enter second number:", value = 0), | ||
radioButtons("operation", label = "Choose operation:", choices = list( | ||
"add", | ||
"subtract", | ||
"multiply", | ||
"divide" | ||
)) | ||
), | ||
|
||
mainPanel( | ||
textOutput("result") | ||
) | ||
) | ||
) | ||
|
||
# Define server logic | ||
server <- function(input, output) { | ||
|
||
result <- reactive({ | ||
# Handling division by zero with req() | ||
if (input$operation == "divide") { | ||
req(input$num2 != 0) | ||
} | ||
|
||
switch(input$operation, | ||
"add" = input$num1 + input$num2, | ||
"subtract" = input$num1 - input$num2, | ||
"multiply" = input$num1 * input$num2, | ||
"divide" = input$num1 / input$num2 | ||
) | ||
}) | ||
|
||
print(input$num1) | ||
# print(result()) | ||
|
||
output$result <- renderText({ | ||
paste("Result:", result()) | ||
}) | ||
|
||
} | ||
|
||
# Run the application | ||
shinyApp(ui = ui, server = server) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
library(shiny) | ||
library(tidyverse) | ||
library(ggbeeswarm) | ||
|
||
data(iris) | ||
|
||
# Define UI | ||
ui <- fluidPage( | ||
titlePanel("My Shiny App"), | ||
sidebarLayout( | ||
sidebarPanel( | ||
sliderInput("dotsize", label = "Dot Size", min = 0.1, max = 5, value = 1, step = 0.1), | ||
downloadButton( | ||
outputId = 'save_violinplot', | ||
label = 'Save plot', | ||
icon = shiny::icon('download') | ||
) | ||
), | ||
mainPanel( | ||
plotOutput("plot") | ||
) | ||
) | ||
) | ||
|
||
# Define server logic | ||
server <- function(input, output) { | ||
violinplot <- reactive({ | ||
ggplot(iris, aes(x=Species, y=Petal.Length)) + | ||
geom_violin(aes(fill=Species)) + | ||
geom_quasirandom(size=input$dotsize) + | ||
geom_boxplot(width=0.1) | ||
}) | ||
|
||
output$plot <- renderPlot({ | ||
violinplot() | ||
}) | ||
|
||
output$save_violinplot <- downloadHandler( | ||
filename = 'plot.pdf', | ||
content = function(file) { | ||
ggsave(file, plot=violinplot(), width=297, height=210, unit='mm') | ||
}) | ||
} | ||
|
||
# Run the application | ||
shinyApp(ui = ui, server = server) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
library(shiny) | ||
library(shinydashboard) | ||
library(tidyverse) | ||
library(ggbeeswarm) | ||
|
||
data(iris) | ||
|
||
# Define UI | ||
ui <- dashboardPage( | ||
dashboardHeader(title = "My Shiny App"), | ||
dashboardSidebar( | ||
sliderInput("dotsize", label = "Dot Size", min = 0.1, max = 5, value = 1, step = 0.1), | ||
downloadButton( | ||
outputId = 'save_violinplot', | ||
label = 'Save plot', | ||
icon = shiny::icon('download') | ||
) | ||
), | ||
dashboardBody( | ||
plotOutput("plot") | ||
) | ||
) | ||
|
||
# Define server logic | ||
server <- function(input, output) { | ||
violinplot <- reactive({ | ||
ggplot(iris, aes(x=Species, y=Petal.Length)) + | ||
geom_violin(aes(fill=Species)) + | ||
geom_quasirandom(size=input$dotsize) + | ||
geom_boxplot(width=0.1) | ||
}) | ||
|
||
output$plot <- renderPlot({ | ||
violinplot() | ||
}) | ||
|
||
output$save_violinplot <- downloadHandler( | ||
filename = 'plot.pdf', | ||
content = function(file) { | ||
ggsave(file, plot=violinplot(), width=297, height=210, unit='mm') | ||
}) | ||
} | ||
|
||
# Run the application | ||
shinyApp(ui = ui, server = server) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
library(shiny) | ||
library(shinydashboard) | ||
library(tidyverse) | ||
library(ggbeeswarm) | ||
|
||
data(iris) | ||
|
||
# Define UI | ||
ui <- dashboardPage( | ||
dashboardHeader( | ||
title = "My Shiny App" | ||
), | ||
dashboardSidebar( | ||
sliderInput("dotsize", label = "Dot Size", min = 0.1, max = 5, value = 1, step = 0.1), | ||
downloadButton( | ||
outputId = 'save_violinplot', | ||
label = 'Save plot', | ||
icon = shiny::icon('download') | ||
) | ||
), | ||
dashboardBody( | ||
tags$head( | ||
includeCSS('05_includeCSS.css') | ||
), | ||
plotOutput("plot") | ||
) | ||
) | ||
|
||
# Define server logic | ||
server <- function(input, output) { | ||
violinplot <- reactive({ | ||
ggplot(iris, aes(x=Species, y=Petal.Length)) + | ||
geom_violin(aes(fill=Species)) + | ||
geom_quasirandom(size=input$dotsize) + | ||
geom_boxplot(width=0.1) | ||
}) | ||
|
||
output$plot <- renderPlot({ | ||
violinplot() | ||
}) | ||
|
||
output$save_violinplot <- downloadHandler( | ||
filename = 'plot.pdf', | ||
content = function(file) { | ||
ggsave(file, plot=violinplot(), width=297, height=210, unit='mm') | ||
}) | ||
} | ||
|
||
# Run the application | ||
shinyApp(ui = ui, server = server) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
aside .btn { | ||
margin: 12px; | ||
color: #000000 !important; | ||
} |
Oops, something went wrong.