Skip to content

Commit 4e07ad9

Browse files
committed
corrected
1 parent dd3b556 commit 4e07ad9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

vignettes/datatable-joins.Rmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,13 @@ x[i, on = .(A >= B)]
590590
In data.table, when using a non-equi join condition (>=, <, etc.), the column from x is retained in the result, while the column from i is not retained unless explicitly selected.
591591

592592
Expected Output
593+
```
593594
A value_x value_i
594595
1: 2 b A
595596
2: 4 d B
596597
3: 5 e C
597598
4: 5 e C
598-
599+
```
599600
If multiple rows in x satisfy the join condition with a single row in i, those rows will be duplicated in the result.
600601

601602
If you want to keep the B column from i, you need to explicitly select it in the result:
@@ -604,12 +605,13 @@ If you want to keep the B column from i, you need to explicitly select it in the
604605
x[i, on = .(A >= B), .(B, A, value_x, value_i)]
605606
```
606607
Updated Output
608+
```
607609
B A value_x value_i
608610
1: 2 2 b A
609611
2: 4 4 d B
610612
3: 5 5 e C
611613
4: 5 5 e C
612-
614+
```
613615
If you want to exclude unmatched rows, you should use nomatch = NULL:
614616

615617
```{r}

0 commit comments

Comments
 (0)