本文介绍了如何在R中访问S4对象的插槽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用程序中的小波,并且使用包wavelets使用函数dwt创建时间序列的DWT.此函数返回类dwt的对象,该对象是具有许多插槽的S4对象:WVlevelsfilter等.

I'm working with wavelets on a program and I'm used the package wavelets to create the DWT of a time series using the function dwt. This function returns an object of class dwt, which is a S4 object with many slots: W, V, levels, filter, and so on.

如何将W作为矢量访问?

推荐答案

@将允许您访问S4对象的插槽.

@ will let you access the slots of an S4 object.

因此,如果您的对象称为wave,则wave@W应该可以为您提供矢量.

So if your object is called wave, then wave@W should get you your vector.

请注意,通常最好的方法是不直接访问插槽,而是通过访问器功能(例如coefs()而不是用$@挖出系数).但是,通常不存在此类功能,因此您必须直接访问插槽.这意味着如果内部实施发生了变化.

Note that often the best way to do this is to not access the slot directly but rather through an accessor function (e.g. coefs() rather than digging out the coefficients with $ or @). However, often such functions do not exist so you have to access the slots directly. This will mean that your code breaks if the internal implementation changes, however.

这篇关于如何在R中访问S4对象的插槽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 04:08