简体   繁体   English

Rstudio 无法从 Github 安装“psimetrica-R”包

[英]Rstudio unable to install 'psimetrica-R' package from Github

I am unable to install a package on Github using Rstudio (version 4.0.4).我无法使用 Rstudio(版本 4.0.4)在 Github 上安装软件包。 The package is here: https://github.com/stmueller/psimetrica-R包在这里: https ://github.com/stmueller/psimetrica-R

I've tried to install directly from console with the following:我尝试使用以下命令直接从控制台安装:

install.packages("psimetrica-R", repos = "https://github.com/stmueller/psimetrica-R.git")

which causes Rstudio to print the following error:这会导致 Rstudio 打印以下错误:

Warning in install.packages : unable to access index for repository https://github.com/stmueller/psimetrica-R.git/src/contrib : cannot open URL 'https://github.com/stmueller/psimetrica-R.git/src/contrib/PACKAGES' Warning in install.packages : package 'psimetrica-R' is not available for this version of R install.packages 中的警告:无法访问存储库https://github.com/stmueller/psimetrica-R.git/src/contrib的索引:无法打开 URL 'https://github.com/stmueller/psimetrica-R。 git/src/contrib/PACKAGES' install.packages 中的警告:包 'psimetrica-R' 不适用于此版本的 R

A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages Warning in install.packages : unable to access index for repository https://github.com/stmueller/psimetrica-R.git/bin/windows/contrib/4.0 : cannot open URL 'https://github.com/stmueller/psimetrica-R.git/bin/windows/contrib/4.0/PACKAGES'您的 R 版本的此包的版本可能在其他地方可用,请参阅https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages中的警告install.packages:无法访问存储库的索引https://github.com/stmueller/psimetrica-R.git/bin/windows/contrib/4.0 :无法打开 URL 'https://github.com/stmueller/psimetrica- R.git/bin/windows/contrib/4.0/PACKAGES'

I also tried:我也试过:

devtools::install_github("stmueller/psimetrica-R")

which causes:什么导致:

Error: Failed to install 'unknown package' from GitHub: HTTP error 404. Not Found错误:无法从 GitHub 安装“未知包”:HTTP 错误 404。未找到

Did you spell the repo owner ( stmueller ) and repo name ( psimetrica-R ) correctly?您是否正确拼写了 repo 所有者 ( stmueller ) 和 repo 名称 ( psimetrica-R )? If spelling is correct, check that you have the required permissions to access the repo.如果拼写正确,请检查您是否具有访问存储库所需的权限。

I've also tried downloading the ZIP file from the repo page and installing with:我还尝试从 repo 页面下载 ZIP 文件并安装:

install.packages("C:/Users/lyamm/Downloads/psimetrica-R-master.zip", repos = NULL, type = "win.binary")

which causes...什么导致...

Installing package into 'C:/Users/lyamm/Documents/R/win-library/4.0' (as 'lib' is unspecified) Warning in install.packages : cannot open compressed file 'psimetrica-R-master/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection将软件包安装到“C:/Users/lyamm/Documents/R/win-library/4.0”(因为未指定“lib”) install.packages 中的警告:无法打开压缩文件“psimetrica-R-master/DESCRIPTION”,可能原因“没有这样的文件或目录” install.packages 中的错误:无法打开连接

Am I doing something wrong?难道我做错了什么? Or is there a problem with / missing files in the package itself?还是包本身有/缺少文件的问题?

A github source repository is not an R package repository like CRAN -- so you cannot use install.packages() . github存储库不是像 CRAN 那样的 R 包存储库——因此您不能使用install.packages()

Instead, use remotes::install_gihub() as in相反,使用remotes::install_gihub()

if (!requireNamespace("remotes", quietly=TRUE)) install.packages("remotes")
remotes::install_github("stmueller/psimetrica-R")

This will install remotes if needed, and use it to install the desired package.如果需要,这将安装remotes ,并使用它来安装所需的软件包。

Or, at least, that would work in principle if psimetrica-R was a regular R source package.或者,至少,如果psimetrica-R是一个常规的 R 源代码包,这在原则上是可行的。 Here it fails because of its layout :在这里它失败了,因为它的布局

> remotes::install_github("stmueller/psimetrica-R")
Error: Failed to install 'unknown package' from GitHub:
  cannot open URL 'https://api.github.com/repos/stmueller/psimetrica-R/contents/DESCRIPTION?ref=HEAD'
> 

So you could fork the repo and make it proper package first.因此,您可以分叉存储库并首先将其打包。 At least open source lets you do that.至少开源可以让你做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM