找回密码
 注册
查看: 6593|回复: 0

R语言:download.file()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 19:52:30 | 显示全部楼层 |阅读模式
download.file(utils)
download.file()所属R语言包:utils

                                        Download File from the Internet
                                         从互联网上下载文件

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This function can be used to download a file from the Internet.
此功能可用于从互联网上下载文件。


用法----------Usage----------


download.file(url, destfile, method, quiet = FALSE, mode = "w",
              cacheOK = TRUE, extra = getOption("download.file.extra"))



参数----------Arguments----------

参数:url
A character string naming the URL of a resource to be downloaded.
要下载一个资源的URL字符串命名。


参数:destfile
A character string with the name where the downloaded file is saved.  Tilde-expansion is performed.
一个下载的文件保存名称的字符串。波浪线进行扩建。


参数:method
Method to be used for downloading files.  Currently download methods "internal", "wget", "curl" and "lynx" are available, and there is a value "auto": see "Details".  The method can also be set through the option "download.file.method": see options().
用于下载文件的方法。目前下载的方法"internal","wget","curl"和"lynx"可,有一个值"auto":见“详细资料”。该方法也可以通过选项"download.file.method":看options()。


参数:quiet
If TRUE, suppress status messages (if any), and the progress bar.
如果TRUE,抑制状态消息(如有),进度条。


参数:mode
character.  The mode with which to write the file.  Useful values are "w", "wb" (binary), "a" (append) and "ab".  Only used for the "internal" method. (See also "Details".)  
字符。该模式与写入文件。有用的值是"w","wb"(二进制),"a"(追加)和"ab"。仅用于"internal"方法。 (亦见“详细资料”。)


参数:cacheOK
logical.  Is a server-side cached value acceptable? Implemented for the "internal", "wget" and "curl" methods.
逻辑。服务器端缓存的值是可以接受的?实施"internal","wget"和"curl"方法。


参数:extra
character vector of additional command-line arguments for the "wget", "curl" and "lynx" methods.
额外的命令行参数为特征向量"wget","curl"和"lynx"方法。


Details

详情----------Details----------

The function download.file can be used to download a single file as described by url from the internet and store it in destfile. The url must start with a scheme such as http://, ftp:// or file://.
功能download.file可以用来下载一个单独的文件,由url从互联网上的描述,并储存在destfile。 url必须启动一个计划,如http://,ftp://或file://。

If method = "auto" is chosen (the default), the internal method is used on Windows.
如果method = "auto"选择(默认),内部的方法是在Windows上使用。

cacheOK = FALSE is useful for http:// URLs, and will attempt to get a copy directly from the site rather than from an intermediate cache.  (Not all platforms support it.) It is used by available.packages.
cacheOK = FALSE是http://网址,将试图得到一份直接从网站,而不是从一个中间缓存。 (并非所有平台都支持它。)它是用来available.packages。

The remaining details apply to method "internal" only.
其余的方法"internal"只适用于。

Note that https:// URLs are only supported if --internet2 or setInternet2(TRUE) was used (to make use of Internet Explorer internals), and then only if the certificate is considered to be valid.
请注意,只支持https://网址,如果--internet2或setInternet2(TRUE)被使用(Internet Explorer的内部使用),然后只有当证书被认为是有效的。

See url for how file:// URLs are interpreted, especially on Windows.  This function does decode encoded URLs.
看到url如何file://URLs被理解,尤其是在Windows上,。此功能解码编码的URL。

The timeout for many parts of the transfer can be set by the option timeout which defaults to 60 seconds.
许多地方的转移超时可以设置选项timeout默认为60秒的。

The level of detail provided during transfer can be set by the quiet argument and the internet.info option.  The details depend on the platform and scheme, but setting internet.info to 0 gives all available details, including all server responses.  Using 2 (the default) gives only serious messages, and 3 or more suppresses all messages.
quiet参数和internet.info选项,可以设置在传输过程中提供的详细程度。细节依赖于平台和计划,但设置internet.info0给所有可用的细节,包括所有服务器的响应。使用2(默认),仅给出了严重的消息,3个或更多的抑制所有消息。

A progress bar tracks the transfer.  If the file length is known, the full width of the bar is the known length.  Otherwise the initial width represents 100 Kbytes and is doubled whenever the current width is exceeded.
一个进度条,跟踪传输。如果文件的长度是已知的,全宽的条形是著名的长度。否则的初始宽度代表100字节和当前的宽度超过一倍。

If mode is not supplied and url ends in one of .gz, .bz2, .xz, .tgz, .zip, .rda or .RData a binary transfer is done.  Since Windows (unlike Unix-alikes) does distinguish between text and binary files, care is needed that other binary file types are transferred with mode = "wb".
mode如果没有提供url的.gz,.bz2,.xz,.tgz,.zip, .rda或.RData二进制传输完成。由于Windows(不像UNIX相似者),不区分文本和二进制文件,需要照顾,其他二进制文件类型mode = "wb"转移。

There is an alternative method if you have Internet Explorer 4 or later installed.   You can use the command line flag --internet2,  or call setInternet2(TRUE) and then  the "Internet Options" of the system are used to choose proxies and so on; these are set in the Control Panel and are those used for Internet Explorer.  That version does not support cacheOK = FALSE.
有一种替代的方法,如果您有Internet Explorer 4或更高版本。您可以使用命令行标志--internet2,或致电setInternet2(TRUE)然后在“Internet选项”系统是用来选择代理等,这些都在控制面板中设置和那些用于Internet Explorer中。该版本不支持cacheOK = FALSE。

Method "wget" can be used with proxy firewalls which require user/password authentication if proper values are stored in the configuration file for wget.
方法"wget"可以使用代理防火墙需要用户名/密码身份验证,如果正确的值存储在配置文件wget。


值----------Value----------

An (invisible) integer code, 0 for success and non-zero for failure.  For the "wget" and "lynx" methods this is the status code returned by the external program.  The "internal" method can return 1, but will in most cases throw an error.
一个(不可见)的整数代码,0成功和失败非零。为"wget"和"lynx"方法,这是由外部程序返回的状态码。 "internal"方法可以返回1,但在大多数情况下,将抛出一个错误。


设置代理----------Setting Proxies----------

This applies to the internal code only.
这适用于只在内部代码。

Proxies can be specified via environment variables. Setting "no_proxy" to "*" stops any proxy being tried. Otherwise the setting of "http_proxy" or "ftp_proxy" (or failing that, the all upper-case version) is consulted and if non-empty used as a proxy site.  For FTP transfers, the username and password on the proxy can be specified by "ftp_proxy_user" and "ftp_proxy_password".  The form of "http_proxy" should be "http://proxy.dom.com/" or "http://proxy.dom.com:8080/" where the port defaults to 80 and the trailing slash may be omitted. For "ftp_proxy" use the form "ftp://proxy.dom.com:3128/" where the default port is 21.  These environment variables must be set before the download code is first used: they cannot be altered later by calling Sys.setenv.
可以通过环境变量指定的代理。设置"no_proxy""*"停止正在尝试任何代理。否则"http_proxy"或"ftp_proxy"(或失败,所有的大写版本)的意见,如果非空作为一个代理网站设置。对于FTP传输,代理的用户名和密码,可以指定"ftp_proxy_user"和"ftp_proxy_password"。 "http_proxy"应该是"http://proxy.dom.com/"或"http://proxy.dom.com:8080/"的形式,默认端口80“结尾的斜线可能会被省略。 "ftp_proxy"使用的形式"ftp://proxy.dom.com:3128/"默认端口是21。这些环境变量必须设置下载代码之前首先使用:他们不能被改变后调用Sys.setenv。

Usernames and passwords can be set for HTTP proxy transfers via environment variable http_proxy_user in the form user:passwd.  Alternatively, http_proxy can be of the form "http://user:pass@proxy.dom.com:8080/" for compatibility with wget.  Only the HTTP/1.0 basic authentication scheme is supported. Under Windows, if http_proxy_user is set to "ask" then a dialog box will come up for the user to enter the username and password.  NB: you will be given only one opportunity to enter this, but if proxy authentication is required and fails there will be one further prompt per download.
用户名和密码,可以通过环境变量http_proxy_user形式user:passwd设置为HTTP代理转让。另外,http_proxy可以形式"http://user:pass@proxy.dom.com:8080/"与wget兼容性。只支持HTTP/1.0的基本身份验证计划。在Windows下,如果http_proxy_user设置为"ask"然后一个对话框来对用户输入的用户名和密码。注意:您将获得进入这个只有一次机会,但如果需要代理身份验证和失败会有一个进一步提示每下载。


注意----------Note----------

Methods "wget" and "lynx" are mainly for historical compatibility, but they and "curl" can be used for URLs (e.g. https:// URLs or those than use cookies) which the internal method does not support.  They will block all other activity on the R process.
方法"wget"和"lynx"主要是由于历史的兼容性,但他们和"curl"可以使用网址(例如https://网址或超过使用cookies)的内部方法确实不支持。他们将阻止所有R进程的其他活动。

For methods "wget", "curl"and "lynx" a system call is made to the tool given by method, and the respective program must be installed on your system and be in the search path for executables.
对于方法"wget","curl"和"lynx"一个系统调用由到method工具,必须在系统上安装和各自的方案,并在搜索可执行文件的路径。


参见----------See Also----------

options to set the HTTPUserAgent, timeout and internet.info options.
options设置HTTPUserAgent,timeout和internet.info选项。

url for a finer-grained way to read data from URLs.
url一个细粒度的方式,从URL读取数据。

url.show, available.packages, download.packages for applications.
url.show,available.packages,download.packages的应用。

Contributed package RCurl provides more comprehensive facilities to download from URLs.
贡献包RCurl提供更全面的设施,从URL下载。

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 21:19 , Processed in 0.024140 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表