Skip to content

Commit dd94b92

Browse files
Use rowwiseDT in vignette construction (#7083)
* Use rowwiseDT in vignette construction * don't print the table, it should be pretty clear from the code, now looks a bit redundant
1 parent e1409e8 commit dd94b92

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

vignettes/datatable-joins.Rmd

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,21 @@ To illustrate how to use the method available with real life examples, let's sim
4343
1. Defining a `data.table` where each product is represented by a row with some qualities, but leaving one product without `id` to show how the framework deals with ***missing values***.
4444

4545
```{r}
46-
Products = data.table(
47-
id = c(1:4,
48-
NA_integer_),
49-
name = c("banana",
50-
"carrots",
51-
"popcorn",
52-
"soda",
53-
"toothpaste"),
54-
price = c(0.63,
55-
0.89,
56-
2.99,
57-
1.49,
58-
2.99),
59-
unit = c("unit",
60-
"lb",
61-
"unit",
62-
"ounce",
63-
"unit"),
64-
type = c(rep("natural", 2L),
65-
rep("processed", 3L))
46+
Products = rowwiseDT(
47+
id=, name=, price=, unit=, type=,
48+
1L, "banana", 0.63, "unit", "natural",
49+
2L, "carrots", 0.89, "lb", "natural",
50+
3L, "popcorn", 2.99, "unit", "processed",
51+
4L, "soda", 1.49, "ounce", "processed",
52+
NA, "toothpaste", 2.99, "unit", "processed"
6653
)
67-
68-
Products
6954
```
7055

7156
2. Defining a `data.table` showing the proportion of taxes to be applied for processed products based on their units.
7257

7358
```{r}
7459
NewTax = data.table(
75-
unit = c("unit","ounce"),
60+
unit = c("unit", "ounce"),
7661
type = "processed",
7762
tax_prop = c(0.65, 0.20)
7863
)

0 commit comments

Comments
 (0)