首先给大家拜年,祝大家马年阖家欢乐,健康平安!同时也感谢大家对于我们的云计算系统的支持!(您可以访问我们的网站来使用云数据挖掘系统:www.foam-buffalo.com,也查看下面的帖子来了解我们系统的详细情况:免费云数据挖掘系统指南!
https://bbs.pinggu.org/forum.php?mod=viewthread&tid=2855736&from^^uid=79252)
我们的系统从计算引擎到操作界面都是由R编写的,然后放置在Amazon EC2弹性云计算系统上面。 不少朋友写信或者回帖咨询如何编写自己的R应用,为了感谢大家的支持,我们决定逐步开源,供大家学习参考。
我们的APP 是 利用R的SHINY 包写的,这个包是由著名的Rstudio开发的。Rstudio开发的IDE(也就是给赋予R操作界面)目前是主流的R操作界面,在这里也强烈推荐一下。
首先,大家请先下载R和Rstudio, 然后再下载SHINY包和各种关联包。然后调入shiny包:
library(shiny)
然后设置您的工作文件夹,例如:setwd("/c:/mydocument/firstapp") , 在这个例子里面,您的app的名字就是firstapp拉!
然后建立两个文件,第一个称为ui.R (即操作界面),第二个称为server.R (即计算引擎),并把它们置入文件夹firstapp里面。
首先是server.R的内容:
shinyServer(function(input, output) { output$main_plot <- renderPlot({ hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks), xlab = "Duration (minutes)", main = "Geyser eruption duration") if (input$individual_obs) { rug(faithful$eruptions) } if (input$density) { dens <- density(faithful$eruptions, adjust = input$bw_adjust) lines(dens, col = "blue") } })})
下面是 ui.R的内容:
shinyUI(bootstrapPage( selectInput(inputId = "n_breaks", label = "Number of bins in histogram (approximate):", choices = c(10, 20, 35, 50), selected = 20), checkboxInput(inputId = "individual_obs", label = strong("Show individual observations"), value = FALSE), checkboxInput(inputId = "density", label = strong("Show density estimate"), value = FALSE), plotOutput(outputId = "main_plot", height = "300px"), # Display this only if the density is shown conditionalPanel(condition = "input.density == true", sliderInput(inputId = "bw_adjust", label = "Bandwidth adjustment:", min = 0.2, max = 2, value = 1, step = 0.2) )))


雷达卡


:

大家会才是真的会

京公网安备 11010802022788号







