NAME

R::YapRI::Robject::Rattributes

A module to store R attributes for an object

SYNOPSIS

use R::YapRI::Robject::Rattributes;

my $rattr = R::YapRI::Rattributes->new();

$rattr->set_names(["X", "Y"]);
my @names = @{$rattr->get_names()};

$rattr->set_dim([5,5]);
my @dim = @{$attr->get_dim()};

$rattr->set_dimnames([["a", "b", "c"], ["x", "y", "z"]]);
my @dimnames_arefs = @{$rattr->set_dimnames()};

$rattr->set_rownames(["x", "y", "z"]);
my @rownames_arefs = @{$rattr->set_rownames()};

$rattr->set_class("data.frame");
my $class = $attr->get_class();

$rattr->set_tsp($start, $end, $frequency);
my ($start, $end, $frequency) = $attr->get_tsp();

DESCRIPTION

Create a R::YapRI::Robject::Rattributes object, used by R::YapRI::Robject to define the attributes for an Robject.

There are 5 basic attributes for R objects (names, dim, dimnames, class and tsp) (for more info http://cran.r-project.org/doc/manuals/R-lang.html#Attributes)

It also has an special case, row.names for data.frames.

AUTHOR

Aureliano Bombarely <aurebg@vt.edu>

CLASS METHODS

The following class methods are implemented:

(*) CONSTRUCTORS:

It has a simple constructor using new() function.

Any of the accessors can be used as function arguments to set the accessor value during the object creation.

constructor new

Usage: my $rattr = R::YapRI::Robject::Rattributes->new($acc_href);

Desc: Create a new R::YapRI::Robject::Rattributes object.

Ret: a R::YapRI::Robject::Rattributes object

Args: $acc_href, an accessor hash ref. with the following key/value pairs:
      names    => arrayref. of strings (generally used with vectors and lists)
      dim      => arrayref. of positive integers.
      dimnames => arrayref. of arrayref. of strings.
      rownames => arrayref. of rownames (generally used with data.frames)
      class    => an scalar defining the class
      tsp      => an arrayref. with three members: start, end and frequency.
      
Side_Effects: Die if the accessor hashref. is not a hash ref. or it is 
              has a different accessor than names, dim, dimnames, class or
              tsp.

Example: my $rattr = R::YapRI::Robject::Rattributes->new($acc_href);        

(*) ACCESSORS:

There are a couple of functions (get/set) for accessors

get/set_names

Usage: my $names_aref = $rattr->get_names();
       $rattr->set_names($names_aref); 

Desc: Get/Set the names attributes to Rattributes object

Ret: Get: $names_aref, an array ref. with names attribute
     Set: None

Args: Get: None
      Set: $names_aref, an array ref. with names attribute

Side_Effects: Get: None
              Set: Die if the argument supplied is not an array ref.

Example: my @names = @{$rattr->get_names()};
         $rattr->set_names(\@names); 

get/set_dim

Usage: my $dim_aref = $rattr->get_dim();
       $rattr->set_dim($dim_aref); 

Desc: Get/Set the dim (dimension) attribute to Rattributes object

Ret: Get: $dim_aref, an array ref. with dim (integers) attribute
     Set: None

Args: Get: None
      Set: $dim_aref, an array ref. with dim (integers) attribute

Side_Effects: Get: None
              Set: Die if the argument supplied is not an array ref.
                   Die if the elements of the array ref. are not integers.

Example: my @dim = @{$rattr->get_dim()};
         $rattr->set_dim(\@dim); 

get/set_dimnames

Usage: my $dimnames_arefaref = $rattr->get_dimnames();
       $rattr->set_dimnames($dimnames_arefaref); 

Desc: Get/Set the dimnames attribute to Rattributes object.

Ret: Get: $dimnames_arefaref, an array ref. of array references 
          with dimnames attributes
     Set: None

Args: Get: None
      Set: $dimnames_arefaref, an array ref. of array references 
           with dimnames attribute

Side_Effects: Get: None
              Set: Die if the argument supplied is not an array ref.
                   Die if the elements of the array ref. are not array refs.

Example: my @dimnames_aref = @{$rattr->get_dimnames()};
         $rattr->set_dimnames([ ['A', 'B'], ['x', 'y'] ]); 

get/set_rownames

Usage: my $rownames_aref = $rattr->get_rownames();
       $rattr->set_rownames($rownames_aref); 

Desc: Get/Set the row.names attributes to Rattributes object

Ret: Get: $rownames_aref, an array ref. with row.names attribute
     Set: None

Args: Get: None
      Set: $rownames_aref, an array ref. with row.names attribute

Side_Effects: Get: None
              Set: Die if the argument supplied is not an array ref.

Example: my @rownames = @{$rattr->get_rownames()};
         $rattr->set_rownames(\@rownames); 

get/set_class

Usage: my $class = $rattr->get_class();
       $rattr->set_class($class); 

Desc: Get/Set the class attribute to Rattributes object

Ret: Get: $class, a class attribute for an R object
     Set: None

Args: Get: None
      Set: $class, a class attribute for an R object

Side_Effects: Get: None
              Set: Die if no arguments is supplied to this function

Example: my $class = @{$rattr->get_class()};
         $rattr->set_class($class); 

get/set_tsp

Usage: my $tsp_aref = $rattr->get_tsp();
       $rattr->set_tsp($tsp_aref); 

Desc: Get/Set the tsp (time series) attribute to Rattributes object

Ret: Get: $tsp_aref, a tsp array ref. attribute for an R object with three
          elements: $start, $end, $frequency.
     Set: None

Args: Get: None
      Set: $tsp_aref, a tsp array ref. attribute for an R object with three
          elements: $start, $end, $frequency.

Side_Effects: Get: None
              Set: Die if no arguments is supplied to this function.
                   Die if the argument provided is not an array ref.
                   If the array ref. supplied has more than three elements,
                   that array will be modify and the elements beyond 3 will
                   be deleted (last index of the array will be set to 2)

Example: my ($start, $end, $frequency) = @{$rattr->get_tsp()};
         $rattr->set_class([$start, $end, $frequency]); 

ACKNOWLEDGEMENTS

Lukas Mueller

Robert Buels

Naama Menda

Jonathan "Duke" Leto

COPYRIGHT AND LICENCE

Copyright 2011 Boyce Thompson Institute for Plant Research

Copyright 2011 Sol Genomics Network (solgenomics.net)

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.