Skip to content

Instantly share code, notes, and snippets.

@haven-jeon
Created November 9, 2012 05:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haven-jeon/4043783 to your computer and use it in GitHub Desktop.
Save haven-jeon/4043783 to your computer and use it in GitHub Desktop.
shiny test with ggplot2
library(shiny)
library(ggplot2)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
# Function that generates a plot of the distribution. The function
# is wrapped in a call to reactivePlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change
# 2) Its output type is a plot
#
output$distPlot <- reactivePlot(function() {
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
a <- "한글 테스트"
p <- ggplot(as.data.frame(dist), aes(dist)) + geom_histogram(binwidth = diff(range(dist))/30) + ggtitle(enc2utf8(a))
print(p)
})
})
library(shiny)
title <- "안녕 Shiny!"
# Define UI for application that plots random distributions
shinyUI(pageWithSidebar(
# Application title
headerPanel(title),
# Sidebar with a slider input for number of observations
sidebarPanel(
sliderInput("obs",
"Number of observations:",
min = 0,
max = 1000,
value = 500)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment