获取 R 包中要在 LaTex 中使用的函数列表
我曾经
library(help="stats")$"info"[[2]]
在 stats
中获取可用函数的列表及其描述。我想使用 xtable
制作一个表格,以便在 LaTex 的 Sweave
中使用。
我在 R: 中使用此命令
library(xtable)
xtable(library(help="stats")$"info"[[2]])
并收到以下错误消息:
Error in UseMethod("xtable") :
no applicable method for 'xtable' applied to an object of class "character"
如果有人指导我执行此操作,我将非常感激。提前致谢。
I used
library(help="stats")$"info"[[2]]
to get the list of available functions with their description in stats
. I'd like to make a table out of this using xtable
to be use in Sweave
for LaTex.
I used this command in R:
library(xtable)
xtable(library(help="stats")$"info"[[2]])
and got the following error message:
Error in UseMethod("xtable") :
no applicable method for 'xtable' applied to an object of class "character"
I'd highly appreciate if someone guide me to do this. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该错误表明
xtable
没有接受character
对象(例如您的输入)的方法。根据xtable 库的文档,xtable 接受data.frame
对象(等等),并且还允许您为不同的对象扩展库。您可以从methods(xtable)
中查看已接受对象的列表。所以我的建议是将
library(help="stats")$"info"[[2]]
中的数据加载到数据框中并将其传递给xtable
反而。The error is indicating that
xtable
does not have a method for acceptingcharacter
objects, such as your input. Per the documentation for the xtable library, xtable acceptsdata.frame
objects (among others), and also allows you to extend the library for different objects. You can see a listing of the accepted objects frommethods(xtable)
.So my suggestion would be to load the data from
library(help="stats")$"info"[[2]]
into a data frame and pass that toxtable
instead.以下是我完成帕特里克建议的任务的方法(在我看到他的答案之前):
您可能想要重命名数据框的列,但这确实会为您提供容纳您指定的 300 多行输出所需的多页乳胶输出。
Here is how I did the task the Patrick advises (before I saw his answer):
You will probably want to renames the dataframe's columns but this does get you the multi-page latex output needed to accommodate that 300+ line output that you specified.