logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Statistics::R::REXP - base class for R objects ("SEXP"s)

Author

       Davor Cubranic <cubranic@stat.ubc.ca>

Bugs And Limitations

       Classes in the "REXP" hierarchy are intended to be immutable. Please do not try to change their value  or
       attributes.

       More "is_*" accessors should be added.

       There are no known bugs in this module. Please see Statistics::R::IO for bug reporting.

Description

       An object of this class represents a native R object. This class cannot be directly instantiated (it will
       die if you call "new" on it), because it is intended as a base abstract class with concrete subclasses to
       represent specific object types.

       An R object has a value and an optional set of named attributes, which themselves are R objects. Because
       the meaning of 'value' depends on the actual object type (for example, a vector vs. a "NULL", in R
       terminology), "REXP" does not provide a generic value accessor method, although individual subclasses
       will typically have one.

Methods

       attributes
           Returns a hash reference to the object's attributes.

       sexptype
           Returns  the  name  of  the  corresponding  R  SEXP  type,  as  listed  in  SEXPTYPE  <http://cran.r-
           project.org/doc/manuals/r-release/R-ints.html#SEXPTYPEs>.

       to_pl
           Returns Perl representation of  the  object's  value.  This  is  an  abstract  method;  see  concrete
           subclasses for the value returned by specific object types, as well as the way to access the R (-ish)
           value of the object, if such makes sense.

       is_null
           Returns  TRUE if the object is an R "NULL" object. In "REXP"'s class hierarchy, this is the case only
           for "Statistics::REXP::Null".

       is_vector
           Returns TRUE if the object is an R vector object. In "REXP"'s class hierarchy, this is the case  only
           for "Statistics::REXP::Vector" and its descendants.

       inherits CLASS_NAME
           Returns  TRUE  if  the object is an instance of R S3-style class "CLASS_NAME", in the same fashion as
           the          R          function           "base::inherits           <http://stat.ethz.ch/R-manual/R-
           patched/library/base/html/class.html>".

Name

       Statistics::R::REXP - base class for R objects ("SEXP"s)

Overloads

       "REXP"  overloads  the  stringification,  "eq"  and "ne" methods; subclasses further specialize for their
       types if necesssary.

Support

       See Statistics::R::IO for support and contact information.

Synopsis

           use Statistics::R::REXP;

           # we usually get REXPs from an RDS file:
           my $rexp = Statistics::R::IO::readRDS('file.rds');

           # REXPs are stringifiable
           say $rexp;

           # REXPs can be converted to the closest native Perl data type
           print $rexp->to_pl;

Version

       version 1.0002

See Also