Learn R Programming

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:

SizeApprox 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.

salescustomerproductstoreorderorderrowsfx
order_keyorder_keyorder_key
customer_keycustomer_keycustomer_key
store_keystore_keystore_key
product_keyproduct_keyproduct_key
currency_codefrom_currency

Installation

You can install the package from CRAN or the development version from GitHub:

install.packages("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)

Copy Link

Version

Install

install.packages('contoso')

Monthly Downloads

154

Version

2.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Alejandro Hagan

Last Published

February 4th, 2026

Functions in contoso (2.0.0)

create_contoso_duckdb

Creates DuckDB database with Contoso datasets
calendar

Calendar Dimension Data from the Contonso Dataset
fx

Foreign Exchange Data from the Contonso Dataset
orders

Order Data from the Contonso Dataset
product

Product Data from the Contonso Dataset
customer

Customer Data from the Contonso Dataset
launch_ui

Launch the DuckDB UI in your browser
sales

Sales Data from the Contonso Dataset
store

Store Data from the Contonso Dataset
orderrows

Order Rows Data from the Contonso Dataset