lsf.str
函数返回函数名称和描述,例如如下:
func_names <- lsf.str(envir = asNamespace("dplyr"), pattern="count")
func_names
上述代码的输出是
add_count : function (x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated())
add_count.data.frame : function (x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated())
add_count.default : function (x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated())
add_count_ : function (x, vars, wt = NULL, sort = FALSE)
add_count_impl : function (x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated(), error_call = caller_env())
count : function (x, ..., wt = NULL, sort = FALSE, name = NULL)
count.data.frame : function (x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = group_by_drop_default(x))
count_ : function (x, vars, wt = NULL, sort = FALSE, .drop = group_by_drop_default(x))
count_regroups : function (code)
现在当我跑步时
func_names[1]
输出是[1] "add_count"
。
我希望得到上面输出中所示的完整行(名称和描述),而不仅仅是名称。我在这里缺少什么?
提前感谢您对此问题的调查。
lsf.str
生成 ls_str
类的对象。该对象本身并不包含您在控制台中键入 func_names
时看到的信息。相反,它包含对象的名称以及有关在哪里找到它们的信息。然后,每当您想要显示对象时,它的 print 方法都会查找它们。
如果您只想将其输出为字符串,您可以使用
capture.output
:
func_names <- capture.output(lsf.str(envir = asNamespace("dplyr"), pattern = "count"))
func_names[1]
#> [1] "add_count : function (x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated()) "