Monty  Boehm

Monty Boehm

1670252345

Put Tables in A Vertabelo Data Model Into A Particular Schema

There is more to a database structure than just tables. Tables are logically divided into groups and stored in database schemas. Read along to find out how to include schemas in your ER diagram using Vertabelo.

A database consists of one or more database schemas, and a database schema consists of one or more tables. A good data modeling tool helps you set them all up. In this article, you’ll see how to create database schemas in Vertabelo and assign tables to them.

Need to recall some basics on data modeling? Make sure to check out the article “DATA MODELING BASICS IN 10 MINUTES” before jumping into database schemas.

Let’s get started.

How to Create a Schema in Vertabelo

First things first! Log in to your Vertabelo account and create a model.

Let’s create a physical data model by clicking the Create new document icon in the menu toolbar.

set schema in Vertabelo

Next, we choose the physical data model.

set schema in Vertabelo

Now, we give a name to our model and choose a database engine.

set schema in Vertabelo

Before we start creating tables, let’s create the schemas to be used in this model.

On the right-side panel, you see the Model Properties pane. To create schemas, expand the Additional SQL scripts tab, like this:

set schema in Vertabelo

Now, let’s input the SQL statements for schema creation.

set schema in Vertabelo

The CREATE SCHEMA statement is very straightforward. It creates a schema with the name specified in the statement. Note that there is no semicolon after the last statement. Vertabelo adds it by default as you’ll see in the upcoming examples.

To learn more about the Additional SQL scripts tab, read the article “WHAT ARE ADDITIONAL SQL SCRIPTS AND WHAT DO YOU USE THEM FOR IN VERTABELO?”

Now, our database schemas are ready! The next step is to create tables and assign them to the schemas.

In THIS ARTICLE, you find some good tips on how to work with Vertabelo editor features efficiently.

How to Set a Schema in Vertabelo for Tables

Below is the ER diagram of the Company data model.

set schema in Vertabelo

Starting from the left, the EmployeeDetails table stores the contact details of each employee. That’s why there is a one-to-one link between the Employee and the EmployeeDetails tables. The Employee table stores the department, the position, and the salary amount for each employee. These two tables are in the employees schema.

Next, the Client table stores a unique identification number for each client and a unique identification number of the employee assigned to the client. Each client is assigned to one employee, and each employee is assigned to zero or more clients. Similar to the EmployeeDetails table, the ClientDetails table stores the contact details of each client. These two tables are in the clients schema.

Real-world ER diagrams consist of many tables. Often, it is difficult to locate specific tables in an ER diagram. As an ERD modeler, Vertabelo offers different ways of finding them. Check them all out HERE!

Now, let’s assign the Employee and EmployeeDetails tables to the employees schema.

To do so, we first select the Employee table and go to the Table Properties pane on the right-side panel. In the Additional properties tab, we set our schema as below.

set schema in Vertabelo

Let’s follow the same process for the EmployeeDetails table.

To verify that both the Employee and EmployeeDetails tables are in the employees schema, we generate SQL scripts by selecting each table one by one and clicking the SQL preview button on the right-side panel.

set schema in Vertabelo

The SQL scripts generated for each of the tables start by creating the employees and clients schemas (here is the missing semicolon!).

We know a table is created in a particular schema when a schema name precedes a table name with a dot in between. The syntax is <schema_name>.<table_name>.

In the generated SQL scripts, we see two CREATE TABLE statements that create the Employee and EmployeeDetails tables in the employees schema. Notice the table names used in the CREATE TABLE statements are employees.Employee and employees.EmployeeDetails. It means our tables belong to the employees schema.

Now, let’s assign the Client and ClientDetails tables to the clients schema. The process is the same as shown above for the Employee table.

set schema in Vertabelo

And we get the following SQL scripts:

set schema in Vertabelo

Just like with the employees schema, the Client and the ClientDetails tables are created in the clients schema.

As a data modeling tool, Vertabelo generates scripts not only for creation but also for many others. Make sure to check out THIS ARTICLE to learn more.

How to Set a Default Schema for New Tables in Vertabelo

You may want to have a default schema to which all the newly created tables are assigned. Let’s set it up!

We are going to add more tables to the employees schema. But we don’t want to waste time assigning a schema to each table individually. No problem! We set the employees schema as the default schema for each table created in Vertabelo from now on.

To do so, we go to the Model Properties pane, expand the Default Additional Properties tab, and set the schema value to the employees schema, like this:

set schema in Vertabelo

Let’s create a table to check if it works.

set schema in Vertabelo

We’ve created the Department table assigned to the employees schema by default.

The Department table stores the unique identifier, the name, and the location of each department. For the sake of completeness, the Department table is linked to the Employee table. Each employee is assigned to exactly one department, and each department has one or more employees.

Here is the SQL script for the Department table:

set schema in Vertabelo

As you see, CREATE TABLE creates the Department table in the employees schema, as expected.

Divide and Conquer With Database Schemas

You may wonder why it is beneficial to use multiple schemas in a database. Database schemas let us divide the database and conquer the user access rights to each schema for each type of user.

Let me explain with our Company data model example we have used throughout this article. Imagine a requirement that an employee be able to search clients in the database without being able to access other employees’ data. This is implemented using schemas. In this case, employees have access rights to the clients schema but not to the employees schema.

Now You Know How to Set Schemas in Vertabelo!

Now, you’re all set. Vertabelo is a great data modeling tool that lets you do all this. Go ahead and create your own database with multiple schemas. Good luck!

Original article source at: https://www.vertabelo.com/

#data #table #schema 

Put Tables in A Vertabelo Data Model Into A Particular Schema
Lawrence  Lesch

Lawrence Lesch

1668090145

A Feature-rich Yet Lightweight Data-table Crafted for Angular

ngx-datatable 

ngx-datatable is an Angular component for presenting large and complex data. It has all the features you would expect from any other table but in a light package with no external dependencies. The table was designed to be extremely flexible and light; it doesn't make any assumptions about your data or how you: filter, sort or page it.

It was built for modern browsers using TypeScript, CSS3 and HTML5 and Angular 8.0.0. This is the sister project of the angular-data-table that is designed for Angular 1.x.

Check out the documentation & demos for more information!

See the changelog for recent changes.

Features

  • Handle large data sets ( Virtual DOM )
  • Expressive Header and Cell Templates
  • Horizontal & Vertical Scrolling
  • Column Reordering & Resizing
  • Client/Server side Pagination & Sorting
  • Intelligent Column Width Algorithms ( Force-fill & Flex-grow )
  • Integrated Pager
  • Cell & Row Selection ( Single, Multi, Keyboard, Checkbox )
  • Fixed AND Fluid height
  • Left and Right Column Pinning
  • Row Detail View
  • Decoupled theme'ing with included Google Material theme
  • Light codebase / No external dependencies
  • AoT Compilation Support
  • Universal Support

Installation

To use ngx-datatable in your project install it via npm:

npm i @swimlane/ngx-datatable --save

Credits

ngx-datatable is a Swimlane open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations.

SecOps Hub is an open, product-agnostic, online community for security professionals to share ideas, use cases, best practices, and incident response strategies.

Download Details:

Author: Swimlane
Source Code: https://github.com/swimlane/ngx-datatable 
License: MIT license

#typescript #angular #grid #table #datatable 

A Feature-rich Yet Lightweight Data-table Crafted for Angular
Nat  Grady

Nat Grady

1667476620

Reactable: interactive Data Tables for R

reactable

Interactive data tables for R, based on the React Table library and made with reactR.

Features

  • Sorting, filtering, pagination
  • Grouping and aggregation
  • Built-in column formatting
  • Custom rendering via R or JavaScript — use Shiny HTML tags and HTML widgets in tables
  • Expandable rows and nested tables
  • Conditional styling
  • Works seamlessly within R Markdown documents and Shiny apps

Demos

Installation

You can install reactable from CRAN with:

install.packages("reactable")

Or install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("glin/reactable")

Usage

To create a table, use reactable() on a data frame or matrix:

library(reactable)

reactable(iris)

reactable example using the iris dataset

You can embed tables in R Markdown documents:

```{r}
library(reactable)

reactable(iris)
```

Or use them in Shiny applications:

library(shiny)
library(reactable)

ui <- fluidPage(
  reactableOutput("table")
)

server <- function(input, output) {
  output$table <- renderReactable({
    reactable(iris)
  })
}

shinyApp(ui, server)

To learn more about using reactable, check out the examples below.

Examples

Browser Support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
IE 11*, Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versions

* Support for Internet Explorer 11 was deprecated in reactable v0.3.0.9000.

Download Details:

Author: glin
Source Code: https://github.com/glin/reactable 
License: View license

#r #react #shiny #table 

Reactable: interactive Data Tables for R
Gordon  Matlala

Gordon Matlala

1667302221

Jekyll-toc: A GitHub Pages Compatible Table Of Contents Generator

Jekyll Pure Liquid Table of Contents

GitHub Pages can't run custom Jekyll plug-ins so when generating Tables of Contents (TOCs), you're stuck with either a JavaScript solution or using kramdown's {:toc} option. However, by using {:toc}, you are forced to have that code next to your actual markdown and you can't place it in a layout. This means every. single. post. will need to have the snippet. If you choose the JavaScript approach, that's perfectly fine but what if JS is disabled on someone's browser or your page is just really long and it becomes inefficient.

Instead, I wrote this solution entirely in Liquid and can be used as an {% include %} in any website you want, in any layout you want. Want to see it in action? Here are some awesome websites that I know of using this solution :heart:.

For more information regarding how this include works, read the blog post.

Want anchors next to your Jekyll headings without JavaScript or a plug-in?

Check out the sister project over at allejo/jekyll-anchor-headings.

Usage

Alright, so how do you use it?

Download the toc.html file from the latest release or the master branch

Toss that file in your _includes folder.

Use it in your template layout where you have {{ content }} which is the HTML rendered from the markdown source with this liquid tag:

{% include toc.html html=content %}

Parameters

This snippet is highly customizable. Here are the available parameters to change the behavior of the snippet.

ParameterTypeDefaultDescription
htmlstring*the HTML of compiled markdown generated by kramdown in Jekyll
sanitizeboolfalsewhen set to true, the headers will be stripped of any HTML in the TOC
classstring''a CSS class assigned to the TOC; concat multiple classes with '.'
idstring''an ID to be assigned to the TOC
h_minint1the minimum TOC header level to use; any heading lower than this value will be ignored
h_maxint6the maximum TOC header level to use; any heading greater than this value will be ignored
orderedboolfalsewhen set to true, an ordered list will be outputted instead of an unordered list
item_classstring''add custom class for each list item; has support for %level% placeholder, which is the current heading level
submenu_classstring''add custom class(es) for each child group of headings; has support for %level% placeholder which is the current "submenu" heading level
base_urlstring''add a base url to the TOC links for when your TOC is on another page than the actual content
anchor_classstring''add custom class(es) for each anchor element
skip_no_idsboolfalseskip headers that do not have an id attribute

* This is a required parameter

Deprecated Variables

  • baseurl has been deprecated since 1.1.0, use base_url instead
  • skipNoIDs has been deprecated since 1.1.0, use skip_no_ids instead

Performance

The performance impact of this snippet on your site is pretty negligible. The stats below were gotten from Jekyll's --profile option.

Filename                              | Count |      Bytes |    Time
--------------------------------------+-------+------------+--------

# performance on docs.docker.com from ~Feb 2017
_includes/toc.html                    |   813 |    524.17K |  6.422

# performance on the "Minimal Mistakes" Jekyll theme
_includes/toc.html                    |    94 |     29.43K |  0.413

Download Details:

Author: Allejo
Source Code: https://github.com/allejo/jekyll-toc 
License: BSD-3 or MIT licenses.

#jekyll #github #pages #table #content 

Jekyll-toc: A GitHub Pages Compatible Table Of Contents Generator

Fetch All Records Sqlite3 using Python Eel | Python Desktop App

Python Desktop App Fetch All Records sqlite3 using python eel

In today's tutorial we will build a Python Desktop Application Fetch all sqlite3 records using python eel

Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries.

python eel : https://morioh.com/p/d9714cb91304

Subscribe: https://www.youtube.com/c/Cairocoders/featured  

Source Code

Install

pip install eel

C:\python_dev\table>pip install eel

Install PyAutoGUI

https://pypi.org/project/PyAutoGUI/

pip install PyAutoGUI

C:\python_dev\table>pip install PyAutoGUI

Create Database sqlite3 using python

#createdb.py
import sqlite3
from sqlite3 import Error 
  
def create_connection(db_file):
    """ create a database connection to a SQLite database """
    conn = None
    try:
        conn = sqlite3.connect(db_file)
        print(sqlite3.version)
    except Error as e:
        print(e)
    finally:
        if conn:
            conn.close()
  
  
if __name__ == '__main__':
    create_connection(r"C:\python_dev\table\views\database\storage.db")

run
C:\python_dev\table>python createdb.py

#main.py
import eel
from views.models.fetchdata import showallrecords
import pyautogui #https://pypi.org/project/PyAutoGUI/
 
eel.init('views')
  
@eel.expose
def get_registers():
    select_reg = showallrecords()
    eel.action_out(select_reg)
     
eel.start(
    'index.html',
    size=pyautogui.size()
)

Create Table
 

CREATE TABLE tblemployee (

id INTEGER PRIMARY KEY AUTOINCREMENT,

name VARCHAR (150),

position VARCHAR (150),

office VARCHAR (150)

);

#table\views\models\fetchdata.py
import sqlite3
 
def showallrecords():
    try:
        connect = sqlite3.connect("views/database/storage.db")
        cursor = connect.cursor()
        cursor.execute("SELECT * FROM tblemployee")
        registers = []
        for item in cursor.fetchall():
            #test = item[1]
            #print(test)
            registers.append(item)
        return registers
    except Exception as error:
        print(error)
        msg = "Error"
        return msg

Make your Front-end HTML CSS and Javascript
 

//table\views\index.html
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="/eel.js"></script>
    <link rel="stylesheet" href="css/index.css">
    <link rel="icon" href="img/myglogo.png">
    <title>Python Registration</title>
</head>
<body>
<div class="container">
<p style="text-align:center;"><h2>Python Desktop App Fetch All Records sqlite3 using python eel</h2></p>
<p style="text-align:right;"><button type="button" class="btn">Add New</button></p>
<table id="employeedatatable" class="styled-table">
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Position</th>
        <th>Office</th>
        <th>Action</th>
    </tr>
</table> 
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script>
    $(document).ready(function(){
        eel.get_registers()
    })
         
    eel.expose(action_out)
    function action_out(registers){ 
        //alert("Show Table");
        registers.forEach(showdata)
    }
         
    function showdata(item, index){
        var get_table = document.getElementById("employeedatatable");
        var tr = document.createElement("tr");
        var td = document.createElement("td");
        var td2 = document.createElement("td");
        var td3 = document.createElement("td");
        var td4 = document.createElement("td");
        var td5 = document.createElement("td");
 
        td.innerText = item[0]
        td2.innerText = item[1]
        td3.innerText = item[2]
        td4.innerText = item[3]
                 
        td5.innerHTML = '<button type="button" class="btn" onclick="buttonedit()">Edit</button> | <button type="button" class="btndelete" onclick="buttondelete()">Delete</button>'
        //td5.className = "acoes"
        //td5.setAttribute("onclick","actions(this, 'documents');")
                 
        get_table.appendChild(tr)
        tr.appendChild(td)
        tr.appendChild(td2)
        tr.appendChild(td3)
        tr.appendChild(td4)
        tr.appendChild(td5)
    }
    function buttonedit()
    {
      alert("Edit Records")
    }   
    function buttondelete()
    {
        if(confirm("Are you sure you want to delete this?")) {
            alert("Successfully Deleted");
        }else{
            return false;
        }
    }
 
</script>
</body>
</html>
//table\views\css\index.css
.container {margin:30px;}
.styled-table {
    border-collapse: collapse;width:100%;
    margin: 25px 0;
    font-size: 0.9em;
    font-family: sans-serif;
    min-width: 400px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}
.styled-table thead tr {
    background-color: #009879;
    color: #ffffff;
    text-align: left;
}
.styled-table th,
.styled-table td {
    padding: 12px 15px;
}
.styled-table tr {
    border-bottom: 1px solid #dddddd;
}
.styled-table tr:nth-of-type(even) {
    background-color: #f3f3f3;
}
.styled-table tr:last-of-type {
    border-bottom: 2px solid #009879;
}
.btn {
    background-color: #04AA6D!important;
    border-radius: 5px;color:#ffffff;
    font-size: 17px;
    font-family: 'Source Sans Pro', sans-serif;
    padding: 6px 18px;
}
.btndelete {
    background-color: #cf2e2e!important;
    border-radius: 5px;color:#ffffff;
    font-size: 17px;
    font-family: 'Source Sans Pro', sans-serif;
    padding: 6px 18px;
}

#python 

Fetch All Records Sqlite3 using Python Eel | Python Desktop App

5 Popular Node.js Hash Table Libraries

In today's post we will learn about 5 Popular Node.js Hash Table Libraries. 

Hash tables are a quick way to implement associative arrays, or mappings of key-value pairs. Fast, reliable cuckoo hash table for Node.js.

1 - Simple-hashtable

Javascript implementation of a simple hash table data structure

Basic Usage

Install with npm :

npm install simple-hashtable --save
var SimpleHashTable = require('simple-hashtable');
var hashtable = new SimpleHashTable();

hashtable.isEmpty();
// --> true

hashtable
    .put('node', 'asynchronous, event-driven io for server side javascript')
    .put('mongodb', 'noSQL database');
// API supports method chaining for 'put' method

hashtable.isEmpty();
// --> false

hashtable.size();
// --> 2

hashtable.containsKey('node');
// --> true

hashtable.containsKey('express');
// --> false

hashtable.containsValue('noSQL database');
// --> true;

hashtable.get('node');
// --> asynchronous, event-driven io for server side javascript

hashtable.get('mongodb');
// --> noSQL database

hashtable.keys();
// --> ['node', 'mongodb']

hashtable.values();
// --> ['asynchronous, event-driven io for server side javascript',
//      'noSQL database']

hashtable.put('node', 'server side javascript');
// overwrites old value with new value

hashtable.get('node');
// --> server side javascript

hashtable.remove('mongodb');
// --> true

hashtable.get('mongodb');
// --> -1

hashtable.size();
// --> 1

hashtable.clear();
hashtable.isEmpty();
// --> true

View on Github

2 - JShashtable-nodejs

Port of jshashtable as nodejs package. jshashtable is a standalone implementation of hash table in JavaScript. It associates keys with values, and allows any object to be used as the key (unlike JavaScript's built-in Object, which only allows strings as property names).

Installation:

npm install jshashtable

Usage:

var Hashtable = require('jshashtable');
var typesHash = new Hashtable();

typesHash.put("A string", "string");
typesHash.put(1, "number");

var o = {};
typesHash.put(o, "object");

console.log( typesHash.get(o) ); // "object"

View on Github

3 - Hash-table

Fast, reliable cuckoo hash table for Node.js

Installation

npm install @ronomon/hash-table

A simple comparison, which you can run yourself:

node vanilla.js

Ignoring any GC implications or per-key memory overhead considerations, which are more serious:


                       keySize=16 bytes, valueSize=0 bytes

  @ronomon/hash-table: Inserting 4000000 elements...
  @ronomon/hash-table: 783ms

            new Set(): Inserting 4000000 elements...
            new Set(): 3695ms

       vanilla object: Inserting 4000000 elements...
       vanilla object: 5557ms

View on Github

4 - Expirable-hash-table

Expirable HashTable to enable timeout-based item removal from HashTable.

Install

npm install expirable-hash-table

Use

var ExpirableHashTable = require('expirable-hash-table')

var myTable = new ExpirableHashTable(1000) // default timeout in miliseconds

myTable.set('key', 'value', 3000) // optional timeout in miliseconds

myTable.get('key') // -> value
myTable.remove('key') // -> ExpirableHashTable
myTable.has('key') // -> true/false
myTable.purge() // -> ExpirableHashTable
myTable.toArray() // -> Array
myTable.size() // -> Integer

myTable.on('change', function() {
  // A change event is emitted ever time an item is added, updated or removed
})

myTable.once('<key>:expired', function() {
   // A expired event is emitted when a given item expires. Useful if a specific item wants to be monitored. 
})

View on Github

5 - Kademlia-dht

Network-agnostic Kademlia distributed hash table

Installation

npm install kademlia-dht

Example usage

This example creates two nodes on a mock network, stores a value on one node, then get it on the other node.

'use strict';

var kad = require('kademlia-dht');

// Store a value on one side and get it back on the other side.
//
function demo(dht1, dht2) {
    dht1.set('beep', 'boop', function (err) {
        dht2.get('beep', function (err, value) {
            console.log('%s === %s', 'boop', value);
        });
    });
}

// Spawn a node. A node is composed of two elements: the local Dht and the Rpc.
//
function spawnNode(endpoint, seeds, cb) {
    kad.MockRpc.spawn(endpoint, function (err, rpc) {
        if (err) return cb(err);
        kad.Dht.spawn(rpc, seeds, function (err, dht) {
            if (err) return cb(err);
            cb(err, dht);
        });
    });
}

spawnNode('localhost:9876', [], function (err, dht1) {
    spawnNode('localhost:4321', [dht1.rpc.endpoint], function (err, dht2) {
        demo(dht1, dht2);
    });
});

View on Github

Thank you for following this article. 

Related videos:

Hash Tables - Beau teaches JavaScript

#node #hash #table 

5 Popular Node.js Hash Table Libraries

Interactive widgets to work with tabular data in Julia

TableWidgets

This package contains a few basic widgets to build GUIs to work with tabular data as well as examples of such GUIs.

Examples

To run the examples, you need to activate the respective folder and instantiate it to get all dependencies.

import Pkg
import TableWidgets: examplefolder
Pkg.activate(examplefolder)
Pkg.instantiate()
include(joinpath(examplefolder, "explorer", "sputnik.jl"))

tablewidgetsdemo

Download Details:

Author: Piever
Source Code: https://github.com/piever/TableWidgets.jl 
License: View license

#julia #table #widgets 

Interactive widgets to work with tabular data in Julia
Mike  Kozey

Mike Kozey

1661875752

Excel_table: A Data Table Scrollable and Expanding Sub Row

excel_table

A table widget scrollable when not enough width space, can set locked column like microsoft excel

Features

  • Lock cloums
  • Scrollable rest
  • Effect when scroll
  • Row can expand sub row

Supported platforms

  • Flutter Android
  • Flutter iOS

Installation

Add excel_table: any to your pubspec.yaml dependencies. And import it:

import 'package:excel_table/excel_table.dart';

How to use

Create your table data using ExcelCell ExcelRow ExcelData

Simply create a ExcelTable widget, and pass the required params:

ExcelTable(
  data: excelData,
  headers: List<Widget> [],
  minColumnsWidth: <double>[],
)

See more on example project

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add excel_table

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  excel_table: ^0.0.5

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:excel_table/excel_table.dart';

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:excel_table/excel_table.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late ExcelData data;
  @override
  void initState() {
    super.initState();
    final excelRow1 = ExcelRow(listCell: [
      ExcelCell(content: "Row 1", align: TextAlign.start),
      ExcelCell.empty(),
      ExcelCell.empty(),
      ExcelCell(content: "30%"),
      ExcelCell.empty(),
    ], listSubRow: [
      ExcelRow(
        listCell: [
          ExcelCell(content: ''),
          ExcelCell(content: "30%"),
          ExcelCell.empty(),
          ExcelCell(content: "10.000"),
          ExcelCell.empty(),
        ],
      ),
      ExcelRow(listCell: [
        ExcelCell(content: ''),
        ExcelCell(content: "10%"),
        ExcelCell.empty(),
        ExcelCell(content: "10.000đ"),
        ExcelCell.empty(),
      ]),
    ]);
    final excelRow2 = ExcelRow(listCell: [
      ExcelCell(content: "Row 2", align: TextAlign.start),
      ExcelCell(content: "10%"),
      ExcelCell.empty(),
      ExcelCell(content: "10.000đ"),
      ExcelCell.empty(),
    ]);

    data = ExcelData(
        listRow: [excelRow1, excelRow2],
        initWidth: [80, null, null, null, null]);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Excel Table'),
        ),
        body: Column(
          children: [
            Padding(
              padding: const EdgeInsets.all(12.0),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(8),
                child: ExcelTable(
                  data: data,
                  lockedColumn: 1,
                  headers: const [
                    HeaderWidget(
                      "Column 1",
                      alignment: Alignment.centerLeft,
                    ),
                    HeaderWidget("Column 2"),
                    HeaderWidget("Column 3"),
                    HeaderWidget("Column 4"),
                    HeaderWidget(
                      "Column 5",
                      alignment: Alignment.centerRight,
                    )
                  ],
                  minColumnsWidth: const [80, 80, 80, 80, 80],
                  padding: const EdgeInsets.all(16),
                  lockedDivider: (context, width) => Container(
                    color: Colors.amber,
                    height: 0.5,
                    width: width,
                  ),
                  scrollableDivider: (context, width) => Container(
                    color: Colors.green,
                    height: 0.5,
                    width: width,
                  ),
                  onRightEffect: (context, atRight) => Visibility(
                    visible: !atRight,
                    child: IgnorePointer(
                      ignoring: true,
                      child: Container(
                        decoration: const BoxDecoration(
                            gradient: LinearGradient(
                          begin: Alignment.centerLeft,
                          end: Alignment.centerRight,
                          colors: [Colors.red, Colors.transparent],
                        )),
                        width: 10,
                      ),
                    ),
                  ),
                  onLeftEffect: (context, atLeft) => Visibility(
                    visible: !atLeft,
                    child: IgnorePointer(
                      ignoring: true,
                      child: Container(
                        decoration: const BoxDecoration(
                            gradient: LinearGradient(
                          begin: Alignment.centerLeft,
                          end: Alignment.centerRight,
                          colors: [
                            Color(0x00FFFFFF),
                            Colors.black,
                          ],
                        )),
                        width: 20,
                      ),
                    ),
                  ),
                  emptyCellBuilder: (context) => const Divider(),
                  footerBuilder: (context) => Column(
                    children: [
                      Container(
                        width: double.infinity,
                        height: 10,
                        color: Colors.red,
                      ),
                      const Center(
                        child: Text('Footer'),
                      ),
                      Container(
                        width: double.infinity,
                        height: 30,
                        color: Colors.green,
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

class HeaderWidget extends StatelessWidget {
  final AlignmentGeometry alignment;
  final String title;
  const HeaderWidget(
    this.title, {
    Key? key,
    this.alignment = Alignment.center,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 44,
      padding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 4.0),
      child: Align(
        alignment: alignment,
        child: Text(
          title,
        ),
      ),
    );
  }
}

Download Details:

Author: a313
Source Code: https://github.com/a313/excel_table 
License: MIT license

#flutter #dart #excel #table 

Excel_table: A Data Table Scrollable and Expanding Sub Row

A Desktop Table Widget for Flutter inspired By QT's QTableView

flutter_desktop_table_view

A desktop table widget for flutter inspired by QT's QTableView.

Basic Info

This widget is inspired by QT's QTableView. The goal is to replicate most of its features.

This widget is intended for the desktop platform, but it can be used on any platform... although performance will not be ideal.

What is currently implemented: Lazy load data, sticky headers, scroll bars, scroll with mouse wheel and also middle click + drag, resizable columns and rows, select cells/rows/columns, edit data, up/down/left/right arrows move selected cell, and perhaps some other minor things.

Some things not currently implemented: copy/paste, complex multiple cell selections, cell spans, custom widgets for editing data, and many other things.

Source code really needs some work. But at least it's working.

Installing:

Add the following to your pubspec.yaml file:

dependencies:
  flutter_desktop_table_view: ^0.0.1

How to use

import 'package:flutter/material.dart';

import 'package:flutter_desktop_table_view/flutter_desktop_table_view.dart' show TableView, Index;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TableView Example',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('TableView Example'),
        ),
        body: makeTable(),
      ),
    );
  }
}

Widget makeTable() {
  final data = Map<Index, String>();

  return TableView(
    columnCount: () => 10,
    rowCount: () => 100,
    data: (index) {
      if (data.containsKey(index)) return data[index]!;
      return '${index.row}, ${index.column}';
    },
    setData: (index, value) {
      data[index] = value;
    },
    dataWidget: (index, selected) {
      // currently this is not used, so just returning empty container
      return Container();
    },
    horizontalHeaderData: (column) {
      return 'Col $column';
    },
    verticalHeaderData: (row) {
      return 'Row $row';
    },
  );
}

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_desktop_table_view

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_desktop_table_view: ^0.0.1

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_desktop_table_view/flutter_desktop_table_view.dart'; 

Download Details:

Author: mjredmond

Source Code: https://github.com/mjredmond/flutter_desktop_table_view

#flutter #widget #table 

A Desktop Table Widget for Flutter inspired By QT's QTableView
Nat  Grady

Nat Grady

1661546340

Flextable: Easily Create Customizable Tables

flextable R package

The flextable package provides a framework for easily create tables for reporting and publications. Tables can be easily formatted with a set of verbs such as `bold()`, `color()`, they can receive a header of more than one line, cells can be merged or contain an image. The package make it possible to build any table for publication from a `data.frame`.

set_flextable_defaults(
  font.family = "Arial", font.size = 10, 
  border.color = "gray")

flextable(head(cars)) %>% 
  bold(part = "header") %>% 
  add_footer_lines("The 'cars' dataset")

Tables can be embedded within HTML, PDF, Word and PowerPoint documents from R Markdown documents and within Microsoft Word or PowerPoint documents with package officer. Tables can also be rendered as R plots or graphic files (png, pdf and jpeg).

flextable(mtcars) %>% 
  theme_vanilla() %>% 
  save_as_docx(path = "mytable.docx")

flextable formats

A flextable object is a data.frame representation. An API is available to let R users create tables for reporting and control their formatting properties and their layout. The package provides functions that give control over:

  • header, body and footer content
  • text, paragraphs, cells and border formatting of any element
  • displayed values

Installation

install.packages("flextable")

You can get the development version from GitHub:

devtools::install_github("davidgohel/flextable")

Resources

Documentation

The help pages are in a bookdown located at: https://ardata-fr.github.io/flextable-book/

Manuals are available at: https://davidgohel.github.io/flextable/reference/index.html

A gallery of examples is available here: https://ardata.fr/en/flextable-gallery/

Getting help / questions

If you have questions about how to use the package, visit Stackoverflow and use tags flextable and r Stackoverflow link! You can also use https://github.com/davidgohel/flextable/discussions to start a discussion.

Contributing to the package

Code of Conduct

Anyone getting involved in this package agrees to our Code of Conduct.

Bug reports

When you file a bug report, please spend some time making it easy for me to follow and reproduce. The more time you spend on making the bug report coherent, the more time I can dedicate to investigate the bug as opposed to the bug report.

Contributing to the package development

A great way to start is to contribute an example or improve the documentation.

If you want to submit a Pull Request to integrate functions of yours, please provide:

  • the new function(s) with code and roxygen tags (with examples)
  • a new section in the appropriate vignette that describes how to use the new function
  • corresponding tests in directory tests/testthat.

By using rhub (run rhub::check_for_cran()), you will see if everything is ok. When submitted, the PR will be evaluated automatically on travis and appveyor and you will be able to see if something broke.

The user documentation is available here: https://ardata-fr.github.io/flextable-book/

Download Details:

Author: Davidgohel
Source Code: https://github.com/davidgohel/flextable 

#r #html5 #table 

Flextable: Easily Create Customizable Tables
Nat  Grady

Nat Grady

1661542440

Rhandsontable: A Htmlwidgets Implementation Of Handsontable.js

Rhandsontable

An htmlwidgets implementation of Handsontable.js. Per the website:

Handsontable is a minimalist Excel-like data grid editor for HTML & JavaScript

This library was inspired by the shinyTable package. Most of the original functionality was preserved, and the htmlwidgets framework made it possible to leverage even more of the Handsontable.js functionality.

Note: With v7, handsontable went to a more restrictive license for commercial use. To avoid license violations for existing users, rhandsontable will not update handsontable beyond v6.2.2. This may change in the future if a way is found to manage multiple handsontable versions.

See the vignette for detailed examples and links to shiny apps.

To install from CRAN use

install.packages("rhandsontable")

For the latest development version use

devtools::install_github("jrowen/rhandsontable")

A simple example

library(rhandsontable)

DF = data.frame(int = 1:10,
                numeric = rnorm(10),
                logical = TRUE,
                character = LETTERS[1:10],
                fact = factor(letters[1:10]),
                date = seq(from = Sys.Date(), by = "days", length.out = 10),
                stringsAsFactors = FALSE)

# add a sparkline chart
DF$chart = sapply(1:10, function(x) jsonlite::toJSON(list(values=rnorm(10))))
                                                    
rhandsontable(DF, rowHeaders = NULL) %>%
  hot_col("chart", renderer = htmlwidgets::JS("renderSparkline"))

alt tag

A more involved shiny example

shiny::runGitHub("rhandsontable", "jrowen", subdir = "inst/examples/rhandsontable_corr")

Important note on shiny use: The htmlwidgets package creates widgets as shiny output bindings. The rhandsontable package also attempts to expose the table as a pseudo shiny input binding using handsontable change events (see here for the supported events). This means the table (e.g. hot) can be accessed in shiny using either input$hot or output$hot, but these values may not be in-sync. The timing of updates will depend on the particular reactive path followed by your shiny application.

Since the widget is not currently able to use the standard shiny input binding functionality, you will need to explicitly call the hot_to_r function to convert the handsontable data to an R object.

Two additional inputs are also enabled, input$hot_select and input$hot_comment, which will fire when a cell selection or a comment changes, respectively (if you would like to see more options, please post an issue or create a PR).

This functionality is still evolving, so please don't hesitate to share suggestions and PRs.

See the project website for more details and live examples, and see below for important details on use in shiny apps.

Download Details:

Author: jrowen
Source Code: https://github.com/jrowen/rhandsontable 
License: Unknown, Unknown licenses found

#r #table #javascript 

Rhandsontable: A Htmlwidgets Implementation Of Handsontable.js
Mike  Kozey

Mike Kozey

1661496480

Crud_table: CRUD Table Flutter Consists Of A Lazy Loading Function

CRUD Table Fluttera

CRUD Table Flutter is a package for crating CURD-UI for your entity/object/class easily. It consists of a Lazy loading function, resizable columns, and integrated CRUD Form.

Features

  • Lazy loading Table
  • Resizable columns
  • Integrated CRUD Form
  • Customizable UI

CRUD UI

Lazy loading

Getting started

The package uses Riverpod for state management. So Please ensure you import flutter_riverpod and wrap the app with ProviderScope.

import 'package:flutter_riverpod/flutter_riverpod.dart';

  runApp(
    ProviderScope(
      child: MyApp(),
    ),
  );

See the example project.

Installing:

In your pubspec.yaml

dependencies:
  crud_table: 
import 'package:crud_table/crud_table.dart';

Usage

When you use CrudTable there you have to pass a CurdViewSource field, and it cannot be null
In CurdViewSource you can see there is a function field call emptyEntityFactory there you have to provide an empty Object which you are use with this CRUD UI. 
Ex :
 Let's say you use User.class with this CrudTable, then the emptyEntityFactory will be
 

emptyEntityFactory: () => User();

Note :
Give unique on every FormItem otherwise form data change will not work as we expect.

Check the example project.

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add crud_table

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  crud_table: ^0.0.3

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:crud_table/crud_table.dart';

example/lib/main.dart

import 'package:crud_table/crud_table.dart';
import 'package:crud_table/table/crud_table.dart';
import 'package:crud_table/table/crud_table_row_holder.dart';
import 'package:crud_table/table/form_item.dart';
import 'package:crud_table/table/form_row.dart';
import 'package:crud_table/table/form_section.dart';
import 'package:crud_table_example/user_task.dart';
import 'package:crud_table_example/user_tasks_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() {
  runApp(
    const ProviderScope(
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Expanded(
            child: CrudTable<UserTask>(
              crudViewSource: createCrudSource(),
              onTap: (t) {
                t as UserTask;
              },
            ),
          ),
        ],
      ),
    );
  }

  CrudViewSource createCrudSource() {
    return CrudViewSource(
      columns: ["id", "code", "description", "active"],
      pageLimit: 20,
      rowHeight: 30,
      emptyEntityFactory: () =>
          UserTask(), // here we provide the empty object, which we get back when click on the submit button of the form
      createRows: (data, index) {
        data as UserTask;
        List<Widget> rows = [];
        rows.add(
            Text(data.id.toString(), style: const TextStyle(fontSize: 16)));
        rows.add(Text(data.taskCode.toString(),
            style: const TextStyle(fontSize: 16)));
        rows.add(Text(data.description.toString(),
            style: const TextStyle(fontSize: 16)));
        rows.add(
            Text(data.active.toString(), style: const TextStyle(fontSize: 16)));
        return rows;
      },
      createForm: (data) {
        data as UserTask;

        List<FormSection> fields = [];

        FormSection section1 = FormSection(
            sectionTitle: "System Tasks",
            formRows: () {
              List<FormRow> r = [];
              FormRow r1 = FormRow(formItems: () {
                List<FormItem> items = [];
                items.add(FormItem(
                  ratio: 1,
                  item: TextFormField(
                    key: CrudTableUtil.formFieldKey(data.id),
                    initialValue: CrudTableUtil.formFieldInitValue(data.id),
                    decoration: const InputDecoration(
                      labelText: 'Id',
                      border: OutlineInputBorder(),
                    ),
                    enabled: false,
                  ),
                ));
                items.add(FormItem(
                  ratio: 1,
                  item: TextFormField(
                    key: CrudTableUtil.formFieldKey(data.taskCode),
                    initialValue:
                        CrudTableUtil.formFieldInitValue(data.taskCode),
                    onSaved: (v) {
                      data.taskCode = v;
                    },
                    validator: (value) {
                      if (value!.isEmpty) {
                        return 'Enter The Task Code!';
                      }
                      return null;
                    },
                    decoration: const InputDecoration(
                      labelText: 'Code',
                      border: OutlineInputBorder(),
                    ),
                  ),
                ));
                return items;
              });
              r.add(r1);
              return r;
            });

        FormSection section2 = FormSection(
            sectionTitle: "System Tasks Section 02",
            formRows: () {
              List<FormRow> r = [];
              FormRow r1 = FormRow(formItems: () {
                List<FormItem> items = [];

                items.add(FormItem(
                  ratio: 1,
                  item: TextFormField(
                    key: CrudTableUtil.formFieldKey(data.description),
                    initialValue:
                        CrudTableUtil.formFieldInitValue(data.description),
                    validator: (value) {
                      if (value!.isEmpty) {
                        return 'Enter a Description!';
                      }
                      return null;
                    },
                    onSaved: (v) {
                      data.description = v;
                    },
                    decoration: const InputDecoration(
                      labelText: 'Description',
                      border: OutlineInputBorder(),
                    ),
                  ),
                ));

                return items;
              });
              FormRow r2 = FormRow(formItems: () {
                return [
                  (FormItem(
                    ratio: 1,
                    item: CheckboxListTile(
                      title: const Text("Active"),
                      controlAffinity: ListTileControlAffinity.leading,
                      value: data.active ?? false,
                      onChanged: (bool? value) {
                        setState(() {
                          data.active = value!;
                        });
                      },
                    ),
                  ))
                ];
              });

              r.add(r1);
              r.add(r2);
              return r;
            });

        fields.add(section1);
        fields.add(section2);
        return fields;
      },
      crudActionListener: CrudActionListener<UserTask>(
        add: (data) async {
          UserTasksService userS = UserTasksService.instance!;
          return userS.addTask(data);
        },
        edit: (data) async {
          data as UserTask;
          UserTasksService userS = UserTasksService.instance!;
          return userS.updateTask(data, data.id!.toInt());
        },
        delete: (data) async {
          data as UserTask;
          UserTasksService userS = UserTasksService.instance!;
          return userS.deleteTask(data.id!.toInt());
        },
      ),
      onPageChange: (pagination) async {
        UserTasksService userS = UserTasksService.instance!;
        return userS.getTasks(pagination.pageNumber, pagination.limit);
      },
    );
  }
}

Additional information

Inspired by Vaadin Crud UI Add-on

Download Details:

Author: ireshmw
Source Code: https://github.com/ireshmw/crud_table 
License: Apache-2.0 license

#flutter #dart #table #crud 

Crud_table: CRUD Table Flutter Consists Of A Lazy Loading Function

PeriodicTable.jl: Periodic Table for Julians!

PeriodicTable.jl

A very simple package for accessing elements in the Periodic Table! 🔥

Installation

Since PeriodicTable is registered in Julia's General Registry, you can readily install it with

] add PeriodicTable

Usage

PeriodicTable.jl provides a Julia interface to a small database of element properties for all of the elements in the periodic table. In particular PeriodicTable exports a global variable called elements, which is a collection of Element data structures.

julia> using PeriodicTable

julia> elements
Elements(…119 elements…):
H                                                  He
Li Be                               B  C  N  O  F  Ne
Na Mg                               Al Si P  S  Cl Ar
K  Ca Sc Ti V  Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr
Rb Sr Y  Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I  Xe
Cs Ba    Hf Ta W  Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn
Fr Ra    Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og
Uue                                                   
      La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu    
      Ac Th Pa U  Np Pu Am Cm Bk Cf Es Fm Md No Lr

You can look up elements by name (case-insensitive) via elements["oxygen"], by symbol via elements[:O], or by number via elements[8], for example.

Each element has fields name, appearance, atomic_mass, boil, category, color, density, discovered_by, melt, molar_heat, named_by, number, period, phase, source, spectral_img, summary, symbol, xpos, ypos, shells.

All physical quantities are unitful.

The data is pretty-printed when you look up an element in the Julia REPL. For example:

julia> elements["oxygen"]
Oxygen (O), number 8:
        category: diatomic nonmetal
     atomic mass: 15.999 u
         density: 1.429 g/cm³
   melting point: 54.36 K
   boiling point: 90.188 K
           phase: Gas
          shells: [2, 6]
e⁻-configuration: 1s² 2s² 2p⁴
         summary: Oxygen is a chemical element with symbol O and atomic number 8. It is a member of the chalcogen group on the periodic table and is a highly reactive nonmetal and oxidizing agent that readily forms compounds (notably oxides) with most elements. By mass, oxygen is the third-most abundant element in the universe, after hydrogen and helium.
   discovered by: Carl Wilhelm Scheele
        named by: Antoine Lavoisier
          source: https://en.wikipedia.org/wiki/Oxygen
  spectral image: https://en.wikipedia.org/wiki/File:Oxygen_spectre.jpg
 

Alternatively, you may want to get a list of elements,

julia> elements[1:4]
4-element Array{PeriodicTable.Element,1}:
 Element(Hydrogen) 
 Element(Helium)   
 Element(Lithium)  
 Element(Beryllium)

A nice interactive visualization of the periodic table, based on PeriodicTable.jl, can be found here.

Data by

The data used for this package has been pulled up in parts from here. Some information has been (and will be) added over time.

Developed together with

Facing issues? :scream:

  • Open a PR with the detailed expaination of the issue
  • Reach me out here

Download Details:

Author: JuliaPhysics
Source Code: https://github.com/JuliaPhysics/PeriodicTable.jl 
License: View license

#julia #table 

PeriodicTable.jl: Periodic Table for Julians!
Nat  Grady

Nat Grady

1660990920

R Function & Addin to Easily insert Tables In Rmd Code Chunks

inserttable

inserttable is an RStudio add-in facilitating insertion of nicely formatted tables in R markdown documents or plain R scripts.

Installation

You can install inserttable from GitHub with:

# install.packages("devtools")
devtools::install_github("lbusett/insert_table")

Usage

Upon installing, inserttable registers a new RStudio Addin (Insert Table) that can be used to easily insert a table in a Rmd document. To use it, open a Rmd or R document and select “Addins –> Insert Table”.

There are two main use modes:

Launch the addin with the cursor on a empty line

In this case, a GUI will open allowing you to select the desired output format ( kable, kableExtra, DT and rhandsontable are currently implemented), and to edit the content of the table. After clicking Done the Addin will add in the file the code needed to generate the table in a nice tribble format (thanks to Miles McBain’s datapasta package!) to allow easier additional editing, and also the code needed to render it with the selected output format using some default options, as can be seen below:

IMPORTANT NOTE: Not all output formats play well with knitting to PDF or Word!. kable works everywhere, while DT and rhandsontable work out of the box only if knitting to html. You can make them work on PDF and Word by adding always_allow_html: yes in the yaml header of the Rmd, and installing phantomjs using: webshot::install_phantomjs() (results are not that good, though).

animation_1.gif

A useful feature is that, for larger tables, you can also cut and paste content from a spreadsheet :

animation_2.gif

Obviously, rendering of the table can be tweaked further by changing/adding arguments of the rendering functions in the automatically generated code.

Launch the addin while selecting the name of a variable

In this case, the GUI allows you to select only the desired output format ( it is assumed that the variable you select corresponds to a data frame or similar object containing the data you wish to show as table). After clicking Done the Addin will add in the Rmd document the code needed to render the selected variable as a table with the selected output format. The code will be added at the first empty line below that containing the name of the selected variable.

animation_3.gif

IMPORTANT NOTE: inserttable will make no effort to guarantee that the variable you select is a data.frame. It is up to you to select a meaningful variable!

Usage from the console

You can also use (part of) inserttable functionality from the console by calling function insert_table().

> insert_table(tbl_name = "table_1", nrows = 4, ncols = 4, tbl_format = "DT")

The function will return to the console the code needed to create a empty table of the specified dimensions and render it with the selected format:

animation_4.gif

Download Details:

Author: lbusett
Source Code: https://github.com/lbusett/insert_table 
License: GPL-3.0 license

#r #table #function 

R Function & Addin to Easily insert Tables In Rmd Code Chunks
Nat  Grady

Nat Grady

1660891380

RpivotTable: A R Wrapper for The Great Library Pivottable

rpivotTable: pivottable for R

The rpivotTable package is an R htmlwidget visualization library built around the Javascript pivottable library.

PivotTable.js is a Javascript Pivot Table library with drag'n'drop functionality built on top of jQuery/jQueryUI and written in CoffeeScript (then compiled to JavaScript) by Nicolas Kruchten at Datacratic. It is available under an MIT license

Installation

The rpivotTable package depends on htmlwidgets package so you need to install both packages. You can do this using the devtools package as follows:

devtools::install_github(c("ramnathv/htmlwidgets", "smartinsightsfromdata/rpivotTable"))

Usage

Call the package with

library(rpivotTable)  # No need to explicitly load htmlwidgets: this is done automatically

Just plug in your data.frame or data.table (e.g. dt) to rpivotTable().

It is as simple as this:

data(mtcars)
rpivotTable(mtcars)

The pivot table should appear in your RStudio Viewer or your browser of choice.

Please refer to the examples and explanations here.

rpivotTable parameters decide how the pivot table will look like the firs time it is opened:

  • data can be a data.frame or data.table. Nothing else is needed. If only the data is selected the pivot table opens with nothing on rows and columns (but you can at any time drag and drop any variable in rows or columns at your leasure)
  • rows and cols allow the user to create a report, i.e. to indicate which element will be on rows and columns.
  • aggregatorName indicates the type of aggregation. Options here are numerous: Count, Count Unique Values, List Unique Values, Sum, Integer Sum, Average, Sum over Sum, 80% Upper Bound, 80% Lower Bound, Sum as Fraction of Total, Sum as Fraction of Rows, Sum as Fraction of Columns, Count as Fraction of Total, Count as Fraction of Rows, Count as Fraction of Columns
  • vals specifies the variable to use with aggregatorName.
  • renderers dictates the type of graphic element used for display, like Table, Treemap etc.
  • sorters allow to implement a javascript function to specify the ad hoc sorting of certain values. See vignette for an example. It is especially useful with time divisions like days of the week or months of the year (where the alphabetical order does not work)
  • subtotals will allow to dynamically select / deselect subtotals

For example, to display a pivot table with frequency of colour combinations of eyes and hair, you can specify:

data(HairEyeColor)
rpivotTable(data = HairEyeColor, rows = "Hair",cols="Eye", vals = "Freq", aggregatorName = "Sum", rendererName = "Table", width="100%", height="400px")

This will display a cross tab with the frequency of eyes by hair colour. Dragging & dropping (slicing & dicing) categorical variables in rows and columns changes the shape of the table.

If you want to include it as part of your dplyr / magrittr pipeline, you can do that also:

library(dplyr)
iris %>%
  tbl_df() %>%
  filter( Sepal.Width > 3 ) %>%
  rpivotTable()

Latest news

I'm happy to announce that Nicolas Kruchten has officialy joined the rpivotTable project. Many thanks to him for the work on the current release.

Download Details:

Author: Smartinsightsfromdata
Source Code: https://github.com/smartinsightsfromdata/rpivotTable 
License: View license

#r #wrapper #table 

RpivotTable: A R Wrapper for The Great Library Pivottable