获得“隐藏”信息在plot()和summary()中
我正在 R 中使用 ABC 包,它计算一些可以绘制的统计数据。使用 绘图(来自包中另一个函数的结果作为矩阵)或 摘要(来自包中另一个函数的结果作为矩阵) 显示几个图表/统计数据。 我有兴趣获得所显示的图表之一的最大值。但是,绘制图表的值不会返回或在输入矩阵中使用。 我怎样才能得到它们,或者我怎样才能看到应用了什么函数来构建图表?
I am using the ABC package in R which computes several statistics that can be plotted. Using
plot( the results as matrix from another function in the package ) or
summary( the results as matrix from another function in the package )
several plots/statistics are displayed.
I am interested to get the maximum value of one of the graphs that is displayed. However, the values of the plotted graphs are not returned or used in the input matrix.
How can I get them, or how can I see what function was applied to construct the graph?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,要查看 S3 方法的代码,您可以键入通用方法,后跟一个点。其次是S3级。例如,要查看通过方法
summary
在glm
对象上分派的代码:相同的规则适用于
abc
包,但似乎作者尚未将他们的方法导出到命名空间中。因此,您必须指定abc
包命名空间。尝试:分别用于summary()、plot()、hist()。
正如 Joshua 所指出的,str() 函数有助于查看数据如何存储在对象中。例如,运行
example(abc)
从abc
小插图生成示例后,会生成对象lin2
,该对象属于lin2
类。代码>abc。尝试str(lin2)
显示数据的存储方式。然后,如果您想查看lin2
的调整值,可以尝试lin2$adj.values
。Generally, to view the code for S3 methods, you would type the generic method, followed by a dot. followed by the S3 class. For example, to view the code dispatched on a
glm
object by the methodsummary
:Same rule applies for the
abc
package, however it seems that the authors have not exported their methods into the namespace. Thus, you have to specify theabc
package namespace. Try:for summary(), plot(), hist(), respectively.
As Joshua notes, the str() function is helpful to view how data is stored in an object. For example, after running
example(abc)
to generate the examples from theabc
vignette, the objectlin2
is produced, which is of classabc
. Tryingstr(lin2)
shows how the data is stored. Then if you wanted to see the adjusted values forlin2
, you could trylin2$adj.values
.