R::YapRI::Robject::Rattributes
A module to store R attributes for an object
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();
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.
Aureliano Bombarely <aurebg@vt.edu>
The following class methods are implemented:
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.
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);
There are a couple of functions (get/set) for accessors
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);
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);
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'] ]);
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);
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);
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]);
Lukas Mueller
Robert Buels
Naama Menda
Jonathan "Duke" Leto
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.
To install R::YapRI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm R::YapRI
CPAN shell
perl -MCPAN -e shell install R::YapRI
For more information on module installation, please visit the detailed CPAN module installation guide.