liuyuqi-dellpc 8 years ago
commit
6d3c88a06c
6 changed files with 101 additions and 0 deletions
  1. 4 0
      .gitignore
  2. 31 0
      README.md
  3. 0 0
      requirements.txt
  4. 23 0
      server.R
  5. 13 0
      shiny-demo.Rproj
  6. 30 0
      ui.R

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.Rproj.user
+.Rhistory
+.RData
+.Ruserdata

+ 31 - 0
README.md

@@ -0,0 +1,31 @@
+# segmentfault-hackathon-2015
+
+本项目于2015-10-24 到 2015-10-25截止,利用shiny+docker+ggplot2+RCurl技术,破解了百度识图API,并利用shiny构建了前后端分离的R语言Web开发框架,实践了敏捷开发。
+本项目致力于解决人体基因与膳食解决方案,基于人体基因的某些天然缺陷和食品成分,我们提供了完整的膳食分析和推荐技术,为用户解决科学膳食的问题,母婴、老年用户将成为我们的主力用户。
+本次大赛该项目有幸获得了特别奖,键盘为PORK键盘一个。
+
+技术实现比较粗糙,大家见谅。
+
+需要安装一些依赖包:
+```
+install.packages("shiny",repos="http://mirror.bjtu.edu.cn/cran/")
+install.packages("shinydashboard",repos="http://mirror.bjtu.edu.cn/cran/")
+install.packages("plotrix",repos="http://mirror.bjtu.edu.cn/cran/")
+install.packages("ggplot2",repos="http://mirror.bjtu.edu.cn/cran/")
+install.packages("RCurl",repos="http://mirror.bjtu.edu.cn/cran/")
+# 安装XML依赖
+system("sudo apt-get install libxml2-dev") # ubuntu
+system("sudo yum install libxml2-devel")# CentOS/RHEL
+install.packages("XML",repos="http://mirror.bjtu.edu.cn/cran/")
+install.packages("jpeg",repos="http://mirror.bjtu.edu.cn/cran/")
+```
+```
+# 环境快速搭建
+docker+R+shiny
+
+```
+
+```
+# 运行
+runApp()
+```

+ 0 - 0
requirements.txt


+ 23 - 0
server.R

@@ -0,0 +1,23 @@
+
+# This is the server logic for a Shiny web application.
+# You can find out more about building applications with Shiny here:
+#
+# http://shiny.rstudio.com
+#
+
+library(shiny)
+
+shinyServer(function(input, output) {
+
+  output$distPlot <- renderPlot({
+
+    # generate bins based on input$bins from ui.R
+    x    <- faithful[, 2]
+    bins <- seq(min(x), max(x), length.out = input$bins + 1)
+
+    # draw the histogram with the specified number of bins
+    hist(x, breaks = bins, col = 'darkgray', border = 'white')
+
+  })
+
+})

+ 13 - 0
shiny-demo.Rproj

@@ -0,0 +1,13 @@
+Version: 1.0
+
+RestoreWorkspace: Default
+SaveWorkspace: Default
+AlwaysSaveHistory: Default
+
+EnableCodeIndexing: Yes
+UseSpacesForTab: Yes
+NumSpacesForTab: 2
+Encoding: UTF-8
+
+RnwWeave: Sweave
+LaTeX: pdfLaTeX

+ 30 - 0
ui.R

@@ -0,0 +1,30 @@
+
+# This is the user-interface definition of a Shiny web application.
+# You can find out more about building applications with Shiny here:
+#
+# http://shiny.rstudio.com
+#
+
+library(shiny)
+
+shinyUI(fluidPage(
+
+  # Application title
+  titlePanel("Old Faithful Geyser Data"),
+
+  # Sidebar with a slider input for number of bins
+  sidebarLayout(
+    sidebarPanel(
+      sliderInput("bins",
+                  "Number of bins:",
+                  min = 1,
+                  max = 50,
+                  value = 30)
+    ),
+
+    # Show a plot of the generated distribution
+    mainPanel(
+      plotOutput("distPlot")
+    )
+  )
+))