如何在 Windows 上安装 cran 软件包?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4418076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:47:14  来源:igfitidea点击:

How to install cran packages on Windows?

windowsr

提问by rsk82

I'm typing for example:

我正在输入例如:

install.packages('TTR')

output is:

输出是:

--- Please select a CRAN mirror for use in this session ---
trying URL 'http://mirrors.softliste.de/cran/bin/windows/contrib/2.12/TTR_0.20-2.zip'
Content type 'application/zip' length 237131 bytes (231 Kb)
opened URL
downloaded 231 Kb

package 'TTR' successfully unpacked and MD5 sums checked

The downloaded packages are in
        C:\Documents and Settings\Administrator\Local Settings\Temp\Rtmp33oIzT\downloaded_packages

But then, even after restarting environment functions belonging to that package aren't recognized, for example EMA() -> Error: could not find function "EMA". Is there any command command to actually install these downloaded packages.

但是,即使在重新启动属于该包的环境函数后也无法识别,例如 EMA() -> 错误:找不到函数“EMA”。是否有任何命令命令可以实际安装这些下载的软件包。

There is "R CMD INSTALL" command to use in shell but when I type:

在 shell 中可以使用“R CMD INSTALL”命令,但是当我输入时:

R CMD INSTALL TTR

I get:

我得到:

Warning: invalid package 'TTR'
Error: ERROR: no packages specified

回答by Joshua Ulrich

A copy of An Introduction to Rcomes with your R installation. Had you glanced at the Table of Contents, you would have seen the Packagessection, where your question is answered in the second sentence.

您的 R 安装随附了一份R 简介。如果您看一眼目录,您就会看到“包裹”部分,您的问题在第二句话中得到解答。

回答by Chase

As hinted at in the comment, installing and gaining access to packages is a two step process. You've got the first step down with install.packages()but then you also need to load the library in your R script to gain access to those functions with library(YourPackageHere).

正如评论中所暗示的,安装和获得对包的访问是一个两步过程。您已经完成了第一步,install.packages()但随后您还需要在 R 脚本中加载库,以便使用library(YourPackageHere).

See this questionfor other details.

有关其他详细信息,请参阅此问题