knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
One of the key strengths of dtsmartr is code reproducibility. Every filter, sort, and column selection you configure in the UI is tracked and converted to equivalent programming instructions in real-time.
Once you have filtered or sorted your data: - Click the 📊 Query Code button in the top-right toolbar. - A modal opens showing the exact code required to recreate your current grid state.
The modal generates code in 5 different formats:
- dplyr: Clean Tidyverse syntax (filter(), arrange(), select()).
- Base R: Zero-dependency base R indexing code (df[rows, cols, drop=FALSE]).
- SQL: Standard SQL code (SELECT ... WHERE ... ORDER BY).
- Arrow: High-performance multi-threaded Arrow query instructions.
- DuckDB: Fast in-memory analytical SQL dialect.
Click the Copy button next to any code block to copy it to your clipboard. Paste it directly into your R scripts to reproduce the exact dataset subset.
Apply some filters on the live explorer widget below, click the Query Code button, and copy the generated R/SQL scripts:
library(dtsmartr) dtsmartr(mtcars)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.