Last active
April 18, 2017 21:08
-
-
Save dfjenkins3/124c1c2e91cc86f8f6080692b8729620 to your computer and use it in GitHub Desktop.
Shiny Widget Example
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
library(shiny) | |
hist_widget <- function() { | |
shinyApp( | |
ui = fluidPage( | |
sidebarLayout( | |
sidebarPanel(sliderInput("n", "Bins", 5, 100, 20)), | |
mainPanel(plotOutput("hist")) | |
) | |
), | |
server = function(input, output) { | |
output$hist <- renderPlot( | |
hist(faithful[[2]], breaks = input$n, | |
col = "skyblue", border = "white") | |
) | |
} | |
) | |
} | |
hist_widget() |
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
library(shiny) | |
library(ggplot2) | |
library(plotly) | |
test <- readRDS("tsnedf.rds") | |
tsne_widget <- function(dataset) { | |
clusterChoice <- colnames(dataset)[3:ncol(dataset)] | |
dataset$Sample <- rownames(dataset) | |
shinyApp( | |
ui = fluidPage( | |
sidebarLayout( | |
sidebarPanel(selectInput("colorClusters", "Color Clusters By", clusterChoice)), | |
mainPanel(plotlyOutput("clusterPlot")) | |
) | |
), | |
server = function(input, output) { | |
output$clusterPlot <- renderPlotly({ | |
ggplotly(ggplot(dataset, aes(X1, X2, label=Sample, color=dataset[,input$colorClusters]))+geom_point()) | |
}) | |
} | |
) | |
} | |
tsne_widget(test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment