我想让gWidgets gui的用户访问R帮助页面。下面是一个最小的例子,有两种方法不起作用。这两行代码都直接在R命令窗口(Windows中的RGui)中工作。 R版本3.1.0
更新:已实施jverzani的建议(按钮3)。有用!谢谢!如果您发布它我可以将其标记为已接受的答案。
library(gWidgets)
gui <- function(){
w <- gwindow(title="Access help pages", visible=TRUE)
help1_btn <- gbutton(text="Help 1 (don't work)", container=w)
addHandlerChanged(help1_btn, handler = function(h, ...) {
# Open help page for function.
with(globalenv(), help(matrix, package = base))
print("PRESSED HELP 1!")
} )
help2_btn <- gbutton(text="Help 2 (don't work)", container=w)
addHandlerChanged(help2_btn, handler = function(h, ...) {
# Open help page for function.
help(matrix, package = base)
print("PRESSED HELP 2!")
} )
help3_btn <- gbutton(text="Help 3 (works!)", container=w)
addHandlerChanged(help3_btn, handler = function(h, ...) {
# Open help page for function.
print(help("matrix", help_type="html"))
print("PRESSED HELP 3!")
} )
}
答案 0 :(得分:0)
正如jverzani建议它可以打印帮助输出(请参阅我的更新问题以获得完整示例):
print(help("matrix", help_type="html"))