[R] easy way to find all extractor functions and the datatypes of what they return

Peter Ehlers ehlers at ucalgary.ca
Sat Oct 10 14:33:17 CEST 2009



Robert Wilkins wrote:
> Am I asking for too much:
> for any object that a stat proc returns  ( y <- lm( y~x) , etc ) ) , is there
> a super convenient function like give_all_extractors( y ) that lists all
> extractor functions , the datatype returned , and a text descriptor
> field ("pairwisepval" "lsmean" etc)

I think that you _are_ asing for too much. (But that's not to
say that you shouldn't consider providing code for such a
function yourself.)

> 
> That would just be so convenient.
> 
> What are my options for querying an object so that I can quickly learn
> the extractor functions to pull out the data and manipulate it?
> Will the datatypes returned usually be named vectors and named
> matrices, indiced by categorical values in the data
> ( "Male" "Female"  "Placebo" "DrugB" etc )? If they are indexed by 1 ,
> 2 , 3 , 4 , it's easier to lose track.

The way to learn about extractor functions is to read the help
pages which you would surely do before using any function that
you haven't used previously. ?lm, for example, would point you
to coef, effects, residuals, fitted, vcov. (Be aware, however,
that not all contributed packages provide help of the same
calibre as does base R.)

The other, highly recommended, way to learn about objects in R
is the str() function. Use it often.

As to your question about named objects, R is almost obsessive
about preserving names.

  -Peter Ehlers

> 
> thanks a bunch in advance
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list