我在fields包上度过了一段艰难的时光。
sessioninfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
形成url一切似乎都很好,并且
fields
取决于>或=等于3.0我尝试使用
install.packages
下载该软件包,但得到了一个我以前从未见过的相当奇怪的结果:trying URL 'http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_7.1.tgz'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_7.1.tgz'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
cannot open: HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘fields’ failed
我还尝试直接使用
7.1
和6.9.1(mavericks)
的文件的URL下载:packageurl <- "http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz"
> install.packages(packageurl, contriburl=NULL, type="source")
Warning message:
package ‘http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz’ is not available (for R version 3.1.0)
> packageurl <- "http://cran.r-project.org/bin/macosx/contrib/3.1/fields_7.1.tgz"
> install.packages(packageurl, contriburl=NULL, type="source")
Warning message:
package ‘http://cran.r-project.org/bin/macosx/contrib/3.1/fields_7.1.tgz’ is not available (for R version 3.1.0)
并运行解压后的
.R
文件中的所有.tar
文件sapply(list.files(pattern="[.]R$", path="........fields/R/", full.names=TRUE), source)
但是如果我这样做,那么功能将无法正常工作
> rdist(c(1,1))
Error in .Fortran("radbas", PACKAGE = "fields", nd = as.integer(d), x1 = as.double(x1), :
"radbas" not available for .Fortran() for package "fields"
问题-字段不可用于R 3.1似乎很奇怪,因为许多人都强烈使用它,对此有什么想法吗?
最佳答案
似乎http://cran.ma.imperial.ac.uk上的存储库被弄乱了。有fields_6.9.1.tgz(您可以通过转到http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz进行检查),但是在PACKAGES
文件(由install.packages
用于查找包的url)中有:
Package: fields Version: 7.1 Title: Tools for spatial data Depends: R (>= 3.0), methods, spam, maps Built: R 3.1.0; x86_64-apple-darwin13.1.0; 2014-05-20 04:58:37 UTC; unix Archs: fields.so.dSYM
That is why you got 404 error.
If you want to install by hand you need to either download file and install from local file or use
# cran got 7.1
packageurl <- "http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/fields_7.1.tgz"
# your mirror got 6.9.1
packageurl <- "http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz"
library(devtools)
install_url(packageurl)
我认为这是暂时的问题,有时会显示正确的文件。
Now you can do it with base R:
CHANGES IN R 3.1.1
NEW FEATURES
- install.packages(repos = NULL) now accepts http:// or ftp:// URLs of package archives as well as file paths, and will download as required. In most cases repos = NULL can be deduced from the extension of the URL.
关于r - HTTP状态为 '404 Not Found'时如何安装软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23784729/