Dataset of the 'Contoso' Company

A collection of synthetic datasets simulating sales transactions from a fictional company. The dataset includes various related tables that contain essential business and operational data, useful for analyzing sales performance and other business insights. Key tables included in the package are: - "sales": Contains data on individual sales transactions, including order details, pricing, quantities, and customer information. - "customer": Stores customer-specific details such as demographics, geographic location, occupation, and birthday. - "store": Provides information about stores, including location, size, status, and operational dates. - "orders": Contains details about customer orders, including order and delivery dates, store, and customer data. - "product": Contains data on products, including attributes such as product name, category, price, cost, and weight. - "calendar": A time-based table that includes date-related attributes like year, month, quarter, day, and working day indicators. This dataset is ideal for practicing data analysis, performing time-series analysis, creating reports, or simulating business intelligence scenarios.


CRAN status

Contoso is a synthetic dataset containing sample sales transaction data for the fictional “Contoso” company. It includes various supporting tables for business intelligence, such as customer, store, product, and currency exchange data.

This dataset is perfect for practicing time series analysis, joins, financial modeling, or any business intelligence-related tasks.

It comes with a built-in dataset as well as the ability to create an in-memory database with duckdb

The package comes with the following tables:

  • sales:
    • Contains information about sales transactions, including the total sales amount, customer, store, and product involved.
  • customer:
    • Contains details about customers, such as customer key, name, address, and demographic information.
  • store:
    • Contains information about stores, including store key, name, location, and related details.
  • product:
    • Contains information about products, such as product key, name, category, and price.
  • fx:
    • Contains foreign exchange rate data, mapping currency pairs to their exchange rates on specific dates.
  • calendar:
    • Contains date-related information, including date, week, month, quarter, and year for use in time-based analysis.
  • orders:
    • Contains information about individual orders, including order key, customer key, order date, and store information.
  • orderrows:
    • Contains detailed line items for each order, including product key, quantity, and price for each item in the order.

Built into the package is the 10K row version of the dataset.

Using view(), you can see the columns’ label using the labelled package.

Inspiration to using labelled comes from Crystal Lewis excellent blog post

For larger datasets, use create_contoso_duckdb() with one of the following sizes:

Size Approx Sales Rows
small ~8,000
medium ~2.3 million
large ~47 million
mega ~237 million

Source

The data is originally sourced from the sqlbi github site

Dataset overview

The relationship keys that join each of the tables are listed below.

sales customer product store order orderrows fx
order_key order_key order_key
customer_key customer_key customer_key
store_key store_key store_key
product_key product_key product_key
currency_code from_currency

Installation

You can install the package from CRAN:

install.packages("contoso")

Or install the development version from Codeberg:

# install.packages("pak")
pak::pak("git::https://codeberg.org/usrbinr/contoso")

Example

library(contoso)

# Create a DuckDB connection to Contoso datasets
db <- create_contoso_duckdb(size = "medium")

# Access the sales dataset
db$sales |> head()

# Launch the DuckDB UI to explore all tables interactively
launch_ui(db$con)

# Clean up when done
DBI::dbDisconnect(db$con, shutdown = TRUE)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("contoso")

2.1.0 by Alejandro Hagan, 7 months ago


https://codeberg.org/usrbinr/contoso


Report a bug at https://codeberg.org/usrbinr/contoso/issues


Browse source code at https://github.com/cran/contoso


Authors: Alejandro Hagan [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports DBI, dplyr, cli, duckdb, purrr

Suggests testthat, dbplyr, gt


Suggested by motherduck.


See at CRAN