R包DT无法安装。

4
为了在RStudio中使用以下命令:
DT::datatable(Result, rownames = FALSE)

需要安装DT软件包。如果没有安装,将会出现以下错误:

Error in loadNameSpace(name) : there is no package called 'DT'
Calls: <Anonymous> ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>

但是在调用时

install.packages("DT")

以下发生了以下情况:
Installing package into ‘\\path/to/Documents/R/win-library/3.5(as ‘lib’ is unspecified)
    also installing the dependency ‘htmlwidgets’
    

 There are binary versions available but the source versions are later:
            binary source needs_compilation htmlwidgets  1.5.1  1.5.3             FALSE DT            0.13   0.16             FALSE

installing the source packages ‘htmlwidgets’, ‘DT’

trying URL 'https://cran.rstudio.com/src/contrib/htmlwidgets_1.5.3.tar.gz' Content type 'application/x-gzip' length 323656 bytes (316 KB) downloaded 316 KB

trying URL 'https://cran.rstudio.com/src/contrib/DT_0.16.tar.gz' Content type 'application/x-gzip' length 1511725 bytes (1.4 MB) downloaded 1.4 MB

"\\path\to\Documents" CMD.EXE wurde mit dem oben angegebenen Pfad als aktuellem Verzeichnis gestartet. UNC-Pfade werden nicht untersttzt. Stattdessen wird das Windows-Verzeichnis als aktuelles Verzeichnis gesetzt.
* installing *source* package 'htmlwidgets' ...
** Paket 'htmlwidgets' successfully unpacked and MD5 sum checked
** R
** inst
** byte-compile and prepare package for lazy loading Failed with error:  'there is no package called 'shiny''
** help
*** installing help indices   converting help for package 'htmlwidgets'
    finding HTML links ... fertig
    JS                                      html  
    JSEvals                                 html  
    createWidget                            html   Rd warning: C:/path/to/AppData/Local/Temp/RtmpoJp2TH/R.INSTALL1e04c257a23/htmlwidgets/man/createWidget.Rd:25: file link 'toJSON' in package 'jsonlite' does not exist and so has been treated as a topic
    getDependency                           html  
    htmlwidgets-package                     html  
    htmlwidgets-shiny                       html  
    onRender                                html  
    onStaticRenderComplete                  html   Rd warning: C:/path/to/AppData/Local/Temp/RtmpoJp2TH/R.INSTALL1e04c257a23/htmlwidgets/man/onStaticRenderComplete.Rd:15: file link 'tags' in package 'htmltools' does not exist and so has been treated as a topic
    prependContent                          html   Rd warning: C:path/to/AppData/Local/Temp/RtmpoJp2TH/R.INSTALL1e04c257a23/htmlwidgets/man/prependContent.Rd:15: file link 'tags' in package 'htmltools' does not exist and so has been treated as a topic
    saveWidget                              html  
    scaffoldWidget                          html  
    setWidgetIdSeed                         html  
    sizingPolicy                            html  
** building package indices
** installing vignettes Warning in file(con, "w")   cannot open file '\\path/to/Documents/R/win-library/3.5/htmlwidgets/doc/index.html' : No such file or directory Error in file(con, "w") : connot open connection ERROR: installing vignettes failed
* removing '\\path/to/Documents/R/win-library/3.5/htmlwidgets' In R CMD INSTALL Warning in install.packages :   installation of package ‘htmlwidgets’ had non-zero exit status "\\path\to\Documents" CMD.EXE has been started with stated path from current directory. UNC-paths not supported. Instead Windows directory is set as current directory. ERROR: dependency 'htmlwidgets' is not available for package 'DT'
* removing '\\path/to/Documents/R/win-library/3.5/DT' In R CMD INSTALL Warning in install.packages :   installation of package ‘DT’ had non-zero exit status

The downloaded source packages are in   ‘C:\path\to\AppData\Local\Temp\RtmpYJTyyw\downloaded_packages’

你能给我一些线索,说明出了什么问题以及如何修复吗?


看起来你的 R 版本不支持 htmlwidgets。请尝试使用 install.packages("htmlwidgets", type = "binary") 进行安装。 - Clemsang
谢谢,尝试使用install.packages("DT", type = "binary")也成功了。 - Yahalnaut
1个回答

4

您的 R 版本不支持 htmlwidgets

请使用:

install.packages("htmlwidgets", type = "binary")

如果需要:

install.packages("DT", type = "binary")

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接