本文主要是介绍R语言图形界面的shiny软件包的方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
R和web的相关软件包有rApache, Rhttpd, Rack, Rook。这些软件包不仅需要开发者熟悉R,而且熟悉网页编程语言(html,CSS,JS)。shiny是R语言的web界面软件包,可在R编程环境下执行。shiny包集成了bootstrap、jquery、ajax等特性。
1.shiny软件包应用
1.1 shiny软件包数据
(1)datasets数据集
(2)读数据
fileInput('file1', 'Choose CSV File', accept=c('text/csv', 'text/comma-separated-values,text/plain'))
1.2 hello Shiny例程
>library(shiny)
>runExample("01_hello")
Listening on http://127.0.0.1:3839

1.3 两个R语言程序
shinyUI(fluidPage( #构建用户界面
titlePanel("Hello Shiny!"), #标题栏
sidebarLayout(
sidebarPanel( #侧边栏
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel( #主面板
plotOutput("distPlot")
)
)
))
server.R是服务器端程序。
shinyServer(function(input, output) { #监听,用户行为
# wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should re-execute automatically
# when inputs change
# 2) Its output type is a plot
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white') #直方图
})
})
这篇关于R语言图形界面的shiny软件包的方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!