~/ learn/ afm-112/ cards/ Join, stack, and the named-vector lookup
1 of 10

In R, type the merge() call that joins lines to products on sku and keeps every line, with NA where a SKU has no product.

In R, type the merge() call that joins lines to products on sku and keeps every line, with NA where a SKU has no product.

Answer

merge(lines, products, by = "sku", all.x = TRUE)

all.x = TRUE is the left join — 5 rows, D400 with NA product and price. Without it the default all = FALSE is an inner join with 4 rows.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/19f65a38-849a-4154-88f1-f87a606087d6/flashcard utf-8 LF