The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Frame::Role::Rlike

VERSION

version 0.0059_01

SYNOPSIS

Data::Frame::Role::Rlike - role to provide R-like methods for Data::Frame

METHODS

    head( Int $n=6 )

If $n ≥ 0, returns a new Data::Frame with the first $n rows of the Data::Frame.

If $n < 0, returns a new Data::Frame with all but the last -$n rows of the Data::Frame.

See also: R's head function.

tail

    tail( Int $n=6 )

If $n ≥ 0, returns a new Data::Frame with the last $n rows of the Data::Frame.

If $n < 0, returns a new Data::Frame with all but the first -$n rows of the Data::Frame.

See also: R's tail function.

subset

    subset( CodeRef $select )

subset is a helper method used to take the result of a the $select coderef and use the return value as an argument to "Data::Frame#select_rows" in select_rows>.

The argument $select is a CodeRef that is passed the Data::Frame $select->( $df ); # $df->subset( $select ); and returns a PDL. Within the scope of the $select CodeRef, $_ is set to a Data::Frame::Column::Helper for the Data::Frame $df.

    use Data::Frame::Rlike;
    use PDL;
    my $N  = 5;
    my $df = dataframe( x => sequence($N), y => 3 * sequence($N) );
    say $df->subset( sub {
                           ( $_->('x') > 1 )
                         & ( $_->('y') < 10 ) });
    # ---------
    #     x  y
    # ---------
    #  2  2  6
    #  3  3  9
    # ---------

See also: R's subset function

AUTHORS

  • Zakariyya Mughal <zmughal@cpan.org>

  • Stephan Loyd <sloyd@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014, 2019-2021 by Zakariyya Mughal, Stephan Loyd.

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