R语言单问号、双问号和help的区别与作用
单问号(?): 查看帮助文档的快捷方式。双问号(??): 搜索帮助系统。help命令:查看帮助文档。
详情如下:
1.单问号(?): 查看帮助文档的快捷方式
是help的快捷方式。这个函数提供了查看文档的通道。名称为name的主题(通常是R对象或数据集)的文档可以通过help(“name”)或?name被展示出来。
如 ?duplicated
R语言单问号(?)用法
2.双问号(??): 搜索帮助系统
是help.search()的快捷方式。允许在帮助系统中的(文件)名称、别名、标题、概念或关键字条目(或其任何组合)中,使用模糊匹配或正则表达式匹配的方式搜索给定字符串的文档。
匹配到的帮助条目的名称和标题将以良好的格式显示出来。但是因为Rstudio的bug,双问号(??)和help.search()在rstudio中都无法展示结果。
如,Rstudio中 ??duplicated 无结果
R语言双问号(??)用法
Rstudio中help.search('duplicated') 无结果
但是在RGui中是可以执行??和help.search命令的,例如:
??duplicated 、help.search('duplicated')的结果如下
3.help命令:查看帮助文档。
help命令是帮助系统的主要接口。
如:help("duplicated")
附:rstudio在该问题的bug详情
The problem here is that the port reported and used differs when R attempts to store the results of the search, and later retrieve them when building the Help page. This code helps trace what's going on: debugonce(tools:::httpd)debug(tools:::.httpd_objects)help.search("linear models")When help.search() is called, a set of topics are found and then are 'saved' using the .httpd_objects() function. This gets saved with some port, which is the output of tools::startDynamicHelp(NA). However, later on, httpd() is invoked with a different port. Because of the mismatch in ports, R doesn't discover the previously-saved help objects and just reports a 'No results found' page. More concretely, from what I'm seeing, R asks us to browse to this URL: http://127.0.0.1:22580/doc/html/Search?objects=1&port=22580But the actual URL that the Help pane page points to is: http://127.0.0.1:31077/help/doc/html/Search?objects=1&port=31077I'm guessing we have a filter or something similar that transforms the port in the URL; we likely only want to transform the first instance of that port.
如有疑问,欢迎留言。
|