-
Notifications
You must be signed in to change notification settings - Fork 49
/
README.Rmd
186 lines (136 loc) · 5.59 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
output:
github_document:
html_preview: false
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
library(tidyverse)
library(dm)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
knit_print.grViz <- function(x, ..., options) {
svg <- DiagrammeRsvg::export_svg(x)
svg <- sub('[<]polygon fill="#ffffff"[^/]+/[>]\n', "", svg)
path <- paste0(options$fig.path, options$label, ".svg")
writeLines(svg, path)
knitr::asis_output(paste0('<img src="', path, '" />'))
}
vctrs::s3_register("knitr::knit_print", "grViz")
clean_output <- function(x, options) {
index <- x
index <- gsub("─", "-", index)
index <- strsplit(paste(index, collapse = "\n"), "\n---\n")[[1]][[2]]
writeLines(index, "index.md")
x <- fansi::strip_sgr(x)
x
}
options(cli.num_colors = 256)
local({
hook_source <- knitr::knit_hooks$get("document")
knitr::knit_hooks$set(document = clean_output)
})
# For initial rendering, can be removed
usethis::use_build_ignore("index.md")
```
# [dm](https://dm.cynkra.com/)
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![R build status](https://github.com/cynkra/dm/workflows/rcc/badge.svg)](https://github.com/cynkra/dm/actions)
[![Codecov test coverage](https://codecov.io/gh/cynkra/dm/branch/main/graph/badge.svg)](https://app.codecov.io/gh/cynkra/dm?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/dm)](https://CRAN.R-project.org/package=dm)
[![Launch rstudio.cloud](https://img.shields.io/badge/rstudio-cloud-blue.svg)](https://rstudio.cloud/project/523482)
<!-- badges: end -->
> Are you using multiple data frames or database tables in R? Organize them with dm.
>
> - Use it for data analysis today.
> - Build data models tomorrow.
> - Deploy the data models to your organization's Relational Database Management System (RDBMS) the day after.
## Overview
dm bridges the gap in the data pipeline between individual data frames and relational databases.
It's a grammar of joined tables that provides a consistent set of verbs for consuming, creating, and deploying relational data models.
For individual researchers, it broadens the scope of datasets they can work with and how they work with them.
For organizations, it enables teams to quickly and efficiently create and share large, complex datasets.
dm objects encapsulate relational data models constructed from local data frames or lazy tables connected to an RDBMS.
dm objects support the full suite of dplyr data manipulation verbs along with additional methods for constructing and verifying relational data models, including key selection, key creation, and rigorous constraint checking.
Once a data model is complete, dm provides methods for deploying it to an RDBMS.
This allows it to scale from datasets that fit in memory to databases with billions of rows.
## Features
dm makes it easy to bring an existing relational data model into your R session.
As the dm object behaves like a named list of tables it requires little change to incorporate it within existing workflows.
The dm interface and behavior is modeled after dplyr, so you may already be familiar with many of its verbs.
dm also offers:
- visualization to help you understand relationships between entities represented by the tables
- simpler joins that "know" how tables are related, including a "flatten" operation that automatically follows keys and performs column name disambiguation
- consistency and constraint checks to help you understand (and fix) the limitations of your data
That's just the tip of the iceberg.
See [Getting started](https://dm.cynkra.com/articles/dm.html) to hit the ground running and explore all the features.
## Installation
The latest stable version of the {dm} package can be obtained from [CRAN](https://CRAN.R-project.org/package=dm) with the command
```r
install.packages("dm")
```
The latest development version of {dm} can be installed from R-universe:
```r
# Enable repository from cynkra
options(
repos = c(
cynkra = "https://cynkra.r-universe.dev",
CRAN = "https://cloud.r-project.org"
)
)
# Download and install dm in R
install.packages('dm')
```
or from GitHub:
```r
# install.packages("devtools")
devtools::install_github("cynkra/dm")
```
## Usage
Create a dm object (see [Getting started](https://dm.cynkra.com/articles/dm.html) for details).
```{r}
library(dm)
dm <- dm_nycflights13(table_description = TRUE)
dm
```
dm is a named list of tables:
```{r}
names(dm)
nrow(dm$airports)
dm$flights %>%
count(origin)
```
Visualize relationships at any time:
```{r draw, screenshot.force = FALSE}
dm %>%
dm_draw()
```
Simple joins:
```{r}
dm %>%
dm_flatten_to_tbl(flights)
```
Check consistency:
```{r}
dm %>%
dm_examine_constraints()
```
Learn more in the [Getting started](https://dm.cynkra.com/articles/dm.html) article.
## Getting help
If you encounter a clear bug, please file an issue with a minimal reproducible example on [GitHub](https://github.com/cynkra/dm/issues).
For questions and other discussion, please use [community.rstudio.com](https://forum.posit.co/).
---
License: MIT © cynkra GmbH.
Funded by:
[![energie360°](man/figures/energie-72.png)](https://www.energie360.ch/de/)
<span style="padding-right:50px">
</span>
[![cynkra](man/figures/cynkra-72.png)](https://www.cynkra.com/)
---
Please note that the 'dm' project is released with a [Contributor Code of Conduct](https://dm.cynkra.com/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.