Re: [R] listing components of an object

From: Charilaos Skiadas <>
Date: Sun, 02 Mar 2008 16:45:11 -0500

On Mar 2, 2008, at 4:12 PM, Nair, Murlidharan T wrote:

> Is there a method to list the components of an object, instead of
> looking at the help for that method? Let me be more clear with an
> example
> data(iris)
> ## tune `svm' for classification with RBF-kernel (default in svm),
> ## using one split for training/validation set
> obj <- tune(svm, Species~., data = iris,
> ranges = list(gamma = 2^(-1:1), cost = 2^(2:4)),
> tunecontrol = tune.control(sampling = "fix")
> )
> ## alternatively:
> ## obj <- tune.svm(Species~., data = iris, gamma = 2^(-1:1), cost
> = 2^(2:4))
> summary(obj)
> plot(obj)
> ---------------------------------
> For tune, an object of class tune, including the components:
> best.parameters a 1 x k data frame, k number of parameters.
> best.performance best achieved performance.
> performances if requested, a data frame of all parameter
> combinations along with the corresponding performance results.
> train.ind list of index vectors used for splits into training and
> validation sets.
> best.model if requested, the model trained on the complete training
> data using the best parameter combination.
> I got the above by doing ?tune.
> Is there a function that helps be do this?

Usually str(obj), or possibly as.list(obj) for many objects, will give you the sort of information that I think you want, but what's wrong with ?tune ? In other words, why do you want this list? Typically, it is advisable that one uses methods to access the components of an object, like for instance "coef(obj)" for the coefficients in a model object. This is so that the internal representation of an object can change without breaking your code, and a host of other reasons.

> Thanks ../Murli

Haris Skiadas
Department of Mathematics and Computer Science Hanover College mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 02 Mar 2008 - 21:48:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 02 Mar 2008 - 22:30:19 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive