Giter VIP home page Giter VIP logo

abbymisc's Introduction

名称

SimpleR::Reshape 数据处理转换

说明

接口山寨自R语言的read.table

还有reshape2包:http://cran.r-project.org/package=reshape2

函数

实例参考xt子文件夹

read_table

支持 从文件或arrayref 按行读入数据,转换后输出新的 文件或arrayref

my $r = read_table(
    'reshape_src.csv', 
    skip_head=>1, 
    conv_sub => sub { [ "$_[0][0] $_[0][1]", $_[0][2], $_[0][3] ] }, 

    write_filename => '01.read_table.csv', 
    #skip_sub => sub { $_[0][3]<200 }, 
    #return_arrayref => 1, 
    #sep=>',', 
    #charset=>'utf8', 
);

melt

数据调整,参考R语言的reshape2包

my $r = melt('reshape_src.csv',
    skip_head => 1, 

    names => [ qw/day hour state cnt rank/ ], 

    #skip_sub => sub { $_[0][3]<1000 }, 
    id => [ 0, 1, 2 ],
    measure => [3, 4], 
    melt_filename => '02.melt.csv',
);

cast

数据重组,参考R语言的reshape2包

my $r = cast('02.melt.csv', 
    cast_filename => '03.cast.csv', 

    names => [ qw/day hour state key value/ ], 
    id => [ 0, 1, 2 ],
    measure => 3, 
    value => 4, 

    stat_sub => sub { my ($vlist) = @_; my @temp = sort { $b <=> $a } @$vlist; return $temp[0] }, 
    result_names => [ qw/day hour state cnt rank/ ], 
);

abbymisc's People

Contributors

abbypan avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.