【发布时间】:2014-02-06 06:41:05
【问题描述】:
我使用的是 Win64,无法在 R 上安装“闪亮”包。尝试安装时,会显示以下消息。有人可以把我放在正确的轨道上还是我在这里错过了一些非常愚蠢的东西?
> install.packages("shiny")
Installing package into ‘C:/Users/Ayan/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: unable to access index for repository http://ftp.iitm.ac.in/cran/bin/windows/contrib/3.0
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.0
Warning messages:
1: In open.connection(con, "r") : unable to resolve 'cran.r-project.org'
2: package ‘shiny’ is not available (for R version 3.0.2)
我尝试使用 India, Cloud(0) 作为 CRAN 镜像
ui.R 文件内容:
library(shiny)
# Define UI for application that plots random distributions
shinyUI(pageWithSidebar(
# Application title
headerPanel("Hello Shiny!"),
# Sidebar with a slider input for number of observations
sidebarPanel(
sliderInput("obs",
"Number of observations:",
min = 1,
max = 1000,
value = 500)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
))
server.R 文件的内容:
library(shiny)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
# Expression that generates a plot of the distribution. The expression
# is wrapped in a call to renderPlot 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 <- renderPlot({
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
hist(dist)
})
})
另外,我在安装包“holdOut”时遇到了分类问题。这是它显示的内容:
> install.packages("holdOut")
Installing package into ‘C:/Users/Ayan/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘holdOut’ is not available (for R version 3.0.2)
这两个问题有关系吗?
【问题讨论】:
-
好的...设法以某种方式安装了该软件包,但卡在了下一阶段。这就是我所做的: 1. 在我的 Documents 文件夹中创建了一个名为“shinytest”的文件夹,这是我的 R 2 工作目录。然后我在其中有两个 R 文件 ui.R 和 server.R。当我输入:
-
>library(shiny) 然后 >runApp("shinytest") R 突然退出。有什么想法吗?
-
没有代码...不知道。
-
ui.R 文件的内容: library(shiny) # 为绘制随机分布的应用程序定义 UI shinyUI(pageWithSidebar( # Application title headerPanel("Hello Shiny!"), # Sidebar with a slider input观察次数 sidebarPanel(sliderInput("obs", "观察次数:", min = 1, max = 1000, value = 500)), # 显示生成的分布图 mainPanel( plotOutput("distPlot") ) ))
-
contents of server.R file: library(shiny) # 定义生成和绘制随机分布所需的服务器逻辑 shinyServer(function(input, output) { # 生成分布图的表达式。表达式 # 包含在对 renderPlot 的调用中以指示: # # 1) 它是“反应性的”,因此应该在输入更改时自动 # 重新执行 # 2) 它的输出类型是绘图 # output$distPlot