Skip to content

Commit f80867b

Browse files
Some more grammar adjustments to joins vignette (#7086)
1 parent e18779a commit f80867b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

vignettes/datatable-joins.Rmd

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,21 @@ ProductsKeyed[ProductReceivedKeyed]
204204

205205
#### 3.1.3. Operations after joining
206206

207-
Most of the time after a join is complete we need to make some additional transformations. To make so we have the following alternatives:
207+
Most of the time after joining we need to make some additional transformations. To do so we have the following alternatives:
208208

209-
- Chaining a new instruction by adding a pair of brakes `[]`.
209+
- Chaining a new instruction by adding a pair of brackets `[]`.
210210
- Passing a list with the columns that we want to keep or create to the `j` argument.
211211

212212
Our recommendation is to use the second alternative if possible, as it is **faster** and uses **less memory** than the first one.
213213

214-
215214
##### Managing shared column Names with the j argument
216215

217216
The `j` argument has great alternatives to manage joins with tables **sharing the same names for several columns**. By default all columns are taking their source from the the `x` table, but we can also use the `x.` prefix to make clear the source and use the prefix `i.` to use any column form the table declared in the `i` argument of the `x` table.
218217

219-
Going back to the little supermarket, after updating the `ProductReceived` table with the `Products` table, it seems convenient apply the following changes:
218+
Going back to the little supermarket, after updating the `ProductReceived` table with the `Products` table, suppose we want to apply the following changes:
220219

221-
- Changing the columns names from `id` to `product_id` and from `i.id` to `received_id`.
222-
- Adding the `total_value`.
220+
- Change the columns names from `id` to `product_id` and from `i.id` to `received_id`.
221+
- Add the `total_value`.
223222

224223
```{r}
225224
Products[
@@ -238,9 +237,9 @@ Products[
238237

239238
##### Summarizing with `on` in `data.table`
240239

241-
We can also use this alternative to return aggregated results based columns present in the `x` table.
240+
We can also use this alternative to return aggregated results based on the columns present in the `x` table.
242241

243-
For example, we might interested in how much money we expend buying products each date regardless the products.
242+
For example, we might be interested in how much money we spend buying each product across days.
244243

245244
```{r}
246245
dt1 = ProductReceived[
@@ -250,7 +249,7 @@ dt1 = ProductReceived[
250249
j = .(total_value_received = sum(price * count))
251250
]
252251
253-
252+
# alternative using multiple [] queries
254253
dt2 = ProductReceived[
255254
Products,
256255
on = c("product_id" = "id"),
@@ -263,7 +262,7 @@ identical(dt1, dt2)
263262

264263
#### 3.1.4. Joining based on several columns
265264

266-
So far we have just joined `data.table` base on 1 column, but it's important to know that the package can join tables matching several columns.
265+
So far we have just joined `data.table`s based on 1 column, but it's important to know that the package can join tables matching several columns.
267266

268267
To illustrate this, let's assume that we want to add the `tax_prop` from `NewTax` to **update** the `Products` table.
269268

@@ -275,7 +274,7 @@ NewTax[Products, on = c("unit", "type")]
275274

276275
Use this method if you need to combine columns from 2 tables based on one or more references but ***keeping only rows matched in both tables***.
277276

278-
To perform this operation we just need to add `nomatch = NULL` or `nomatch = 0` to any of the prior join operations to return the same results.
277+
To perform this operation we just need to add `nomatch = NULL` to any of the prior join operations to return the same results.
279278

280279
```{r}
281280
# First Table
@@ -296,7 +295,7 @@ Despite both tables having the same information, there are some relevant differe
296295
- The `id` column in the first table has the same information as the `product_id` in the second table.
297296
- The `i.id` column in the first table has the same information as the `id` in the second table.
298297

299-
### 3.3. Not join
298+
### 3.3. Anti-join
300299

301300
This method **keeps only the rows that don't match with any row of a second table**.
302301

0 commit comments

Comments
 (0)