Skip to content

Commit a346673

Browse files
nitish jhanitish jha
authored andcommitted
updating documentation
1 parent ab491da commit a346673

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

vignettes/datatable-intro.Rmd

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,35 +261,35 @@ setkeyv(flights, "origin")
261261
```
262262

263263
* **Key-based subsetting: `dt["d"]`**
264-
265-
This performs a right join on the key column `x`, resulting in a row with `d` and `NA` for columns not found.
266264

267-
```r
265+
This performs a right join on the key column `x`, resulting in a row with `d` and `NA` for columns not found. When using `setkeyv`, the table is sorted by the specified keys and an internal index is created, enabling binary search for efficient subsetting.
266+
267+
```r
268268
flights["XYZ"]
269-
# Returns:
270-
# origin year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum ...
271-
# 1: XYZ NA NA NA NA NA NA NA NA NA NA NA NA ...
272-
```
269+
# Returns:
270+
# origin year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum ...
271+
# 1: XYZ NA NA NA NA NA NA NA NA NA NA NA NA ...
272+
```
273273

274274
* **Logical subsetting: `dt[x == "d"]`**
275275

276276
This performs a standard subset operation that does not find any matching rows and thus returns an empty `data.table`.
277277

278-
```r
279-
flights[origin == "XYZ"]
280-
# Returns:
281-
# Empty data.table (0 rows and 19 cols): year,month,day,dep_time,sched_dep_time,dep_delay,arr_time,sched_arr_time,arr_delay,...
282-
```
278+
```r
279+
flights[origin == "XYZ"]
280+
# Returns:
281+
# Empty data.table (0 rows and 19 cols): year,month,day,dep_time,sched_dep_time,dep_delay,arr_time,sched_arr_time,arr_delay,...
282+
```
283283

284284
* **Exact match using `nomatch=NULL`**
285285

286286
For exact matches without `NA` for non-existing elements, use `nomatch=NULL`:
287287

288-
```r
289-
flights["XYZ", nomatch=NULL]
290-
# Returns:
291-
# Empty data.table (0 rows and 19 cols): year,month,day,dep_time,sched_dep_time,dep_delay,arr_time,sched_arr_time,arr_delay,...
292-
```
288+
```r
289+
flights["XYZ", nomatch=NULL]
290+
# Returns:
291+
# Empty data.table (0 rows and 19 cols): year,month,day,dep_time,sched_dep_time,dep_delay,arr_time,sched_arr_time,arr_delay,...
292+
```
293293

294294
Understanding these behaviors can help prevent confusion when dealing with non-existing elements in your data.
295295

0 commit comments

Comments
 (0)