RStudio 错误 (Windows): 没有名为 'shinydashboard' 的包

RStudio Error (Windows): There is no package called 'shinydashboard'

It may be the same question as this, however it stood unanswerd

我确实遇到了同样的问题,我无法加载库 "shinydashboard"。我找到了上面的问题,但是解决方案只针对Ubuntu/Linux。我正在使用 RStudio 和 Windows,但无法为我使用该解决方案。

我的代码:

## app.R ##
install.packages("shinydashboard")
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

我收到以下错误消息:

Error in library(shinydashboard) : there is no package called ‘shinydashboard’

将 install.packages 中的 lib 参数更改为

 install.packages("shinydashboard",lib="C:/Program Files/R/R-3.4.1/library")

我收到以下错误: 是:

Warning in install.packages :
  'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable
trying URL 
'https://cran.rstudio.com/bin/windows/contrib/3.4/shinydashboard_0.6.1.zip'
Content type 'application/zip' length 305360 bytes (298 KB)
downloaded 298 KB

package ‘shinydashboard’ successfully unpacked and MD5 sums checked
Warning in install.packages :
  unable to move temporary installation ‘C:\Users\D0282530\Documents\R\win-
library.4\file1e4419db2614\shinydashboard’ to 
‘C:\Users\D0282530\Documents\R\win-library.4\shinydashboard’

The downloaded binary packages are in
    C:\Users\D0282530\AppData\Local\Temp\Rtmpg3TVPL\downloaded_packages
Error in library(shinydashboard) : 
  there is no package called ‘shinydashboard’ 

否:

Warning in install.packages :
  'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable
Error in install.packages : unable to install packages
Error in library(shinydashboard) : 
  there is no package called ‘shinydashboard’

正如@Roland 提到的,软件包安装到了错误的库中(仅适用于我自己的用户帐户)。在尝试将其安装到另一个库并出现写入权限问题后,我终于手动将文件夹复制到第二个(对所有用户可用)库。