Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cross_table

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross_table

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

CrossTable

Cross tabulation (Pivot table) utility to convert table data to a pivot table form.

Source (List table)

oslangprice
winruby123
linuxruby12
macphp270
winjava560
winphp750
linuxjava950
winjava1200
winphp500
macphp10
macjava566
winruby210

 >>> 

Destination (Pivot table)

rubyjavaphp
win33317601250
linux129500
mac0566280

The test code to get the sample table above.

Installation

Add this line to your application's Gemfile:

gem 'cross_table'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cross_table

Usage

Records Count

require 'cross_table'

cross_tbl = CrossTable.counts_from(
  recs: [],         # Source List Table(Enumerable)
  group_rules: [],  # Grouping Rules (Array of Hash)
  y_keys: [],       # Y-axis Keys (Array)
  x_keys: []        # X-axis Keys (Array)
  ret_type: nil     # Type of returned Pivot table. (nil|:xy_titles|:data_only)
)

Sample test code of CrossTable.counts_from

Sample data and group_rule setting

Fields Summary

require 'cross_table'

cross_tbl = CrossTable.sums_from(
  recs: [],         # Source List Table(Enumerable of Hash)
  field: :fld_name  # Target field name to be summarised
  group_rules: [],  # Grouping Rules (Array of Hash)
  y_keys: [],       # Y-axis Keys (Array)
  x_keys: []        # X-axis Keys (Array)
  ret_type: nil     # Type of returned Pivot table. (nil|:xy_titles|:data_only)
)

Sample test code of CrossTable.sums_from

Sample data and group_rule setting

Fields Average

require 'cross_table'

cross_tbl = CrossTable.avgs_from(
  recs: [],         # Source List Table(Enumerable of Hash)
  field: :fld_name  # Target field name to be summarised
  group_rules: [],  # Grouping Rules (Array of Hash)
  y_keys: [],       # Y-axis Keys (Array)
  x_keys: []        # X-axis Keys (Array)
  ret_type: nil     # Type of returned Pivot table. (nil|:xy_titles|:data_only)
)

Sample test code of CrossTable.avgs_from

Sample data and group_rule setting

Arbitrary property of grouped records

require 'cross_table'

cross_tbl = CrossTable.from(
  recs: [],         # Source List Table(Enumerable of Hash)
  group_rules: [],  # Grouping Rules (Array of Hash)
  y_keys: [],       # Y-axis Keys (Array)
  x_keys: []        # X-axis Keys (Array)
  ret_type: nil     # Type of returned Pivot table. (nil|:xy_titles|:data_only)
  &aggr_proc        # Proc/block to get a value from the arg "group_recs"
)

Sample test code of CrossTable.from to get a Minumum value.

Sample data and group_rule setting

Multiple Keys Grouping

Sample test code of using multilpe keys.

Development

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/masa-kunikata/cross_table.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 19 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc