Skip to content

Commit 58dff19

Browse files
committed
corrected file
1 parent 844d97c commit 58dff19

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

vignettes/datatable-joins.Rmd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,9 @@ Products[ProductPriceHistory, on = .(id = product_id), price := i.price]
708708

709709
2) If we need to get the latest price and date (instead of all matches), we can still use := efficiently:
710710
```{r Updating with the Latest Record}
711-
Products[ProductPriceHistory,
711+
Products[ProductPriceHistory,
712712
on = .(id = product_id),
713-
`:=`(price = last(i.price), last_updated = last(i.date)),
713+
`:=`(price = last(i.price), last_updated = last(i.date)),
714714
by = .EACHI]
715715
```
716716
- last(i.price) ensures that only the latest price is selected.
@@ -720,10 +720,9 @@ Products[ProductPriceHistory,
720720
3) When we need to update Products with multiple columns from ProductPriceHistory
721721
```{r Efficient Right Join Update }
722722
cols <- setdiff(names(ProductPriceHistory), 'product_id')
723-
Products[ProductPriceHistory,
724-
on = .(id = product_id),
723+
Products[ProductPriceHistory,
724+
on = .(id = product_id),
725725
(cols) := mget(cols)]
726-
727726
```
728727
- Efficiently updates multiple columns in Products from ProductPriceHistory.
729728
- mget(cols) retrieves multiple matching columns dynamically.

0 commit comments

Comments
 (0)