From 525966dc1183637245936aa5e7591f3852ff1618 Mon Sep 17 00:00:00 2001 From: Floris Vanderhaeghe Date: Wed, 1 May 2024 17:02:44 +0200 Subject: [PATCH] databases.qmd: minor updates * - use `join_by()` instead of `by = ` - a couple of text fixes --- databases.qmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/databases.qmd b/databases.qmd index 8145250af..639b2e40c 100644 --- a/databases.qmd +++ b/databases.qmd @@ -504,7 +504,7 @@ Here's a simple example: ```{r} flights |> - left_join(planes |> rename(year_built = year), by = "tailnum") |> + left_join(planes |> rename(year_built = year), join_by(tailnum)) |> show_query() ``` @@ -597,7 +597,7 @@ flights |> ) ``` -In SQL, the `GROUP BY` clause is used exclusively for summaries so here you can see that the grouping has moved from the `PARTITION BY` argument to `OVER`. +In SQL, the `GROUP BY` clause is used exclusively for summaries so here you can see that the grouping has moved from the `GROUP BY` clause to `OVER`. Window functions include all functions that look forward or backwards, like `lead()` and `lag()` which look at the "previous" or "next" value respectively: @@ -656,8 +656,8 @@ dbplyr's translations are certainly not perfect, and there are many R functions In this chapter you learned how to access data from databases. We focused on dbplyr, a dplyr "backend" that allows you to write the dplyr code you're familiar with, and have it be automatically translated to SQL. We used that translation to teach you a little SQL; it's important to learn some SQL because it's *the* most commonly used language for working with data and knowing some will make it easier for you to communicate with other data folks who don't use R. -If you've finished this chapter and would like to learn more about SQL. -We have two recommendations: +If you've finished this chapter and would like to learn more about SQL, +we have two recommendations: - [*SQL for Data Scientists*](https://sqlfordatascientists.com) by Renée M. P. Teate is an introduction to SQL designed specifically for the needs of data scientists, and includes examples of the sort of highly interconnected data you're likely to encounter in real organizations. - [*Practical SQL*](https://www.practicalsql.com) by Anthony DeBarros is written from the perspective of a data journalist (a data scientist specialized in telling compelling stories) and goes into more detail about getting your data into a database and running your own DBMS.