![fo same as foce sparse data nonmem fo same as foce sparse data nonmem](https://d3i71xaburhd42.cloudfront.net/9dfcda8f9e28a41dd9b51bd0b54ea887f482abba/13-Table1-1.png)
Let’s start by constructing a basic sparse matrix where element (i,j) = TRUE if customer i purchased product j, and FALSE otherwise. RowIdx and ColIdx in the orders table will be the (i,j) location of each record in the resulting matrix.
![fo same as foce sparse data nonmem fo same as foce sparse data nonmem](https://i1.rgstatic.net/publication/303498747_Comparing_the_performance_of_FOCE_and_different_expectation-maximization_methods_in_handling_complex_population_physiologically-based_pharmacokinetic_models/links/59ea1c0faca272cddddb74f0/largepreview.png)
# Build a table of customers custs <- ame ( Customer = c ( "Bob", "Sue", "Ralf", "John", "Mary" )) custs # Customer # 1 Bob # 2 Sue # 3 Ralf # 4 John # 5 Mary # Build a table of products prods <- ame ( Product = c ( "AAA", "BBB", "CCC", "DDD", "EEE", "FFF" )) prods # Product # 1 AAA # 2 BBB # 3 CCC # 4 DDD # 5 EEE # 6 FFF # Build a table of orders: (customer, product, units) triplets orders <- ame ( Customer = c ( "Bob", "Bob", "Sue", "Sue", "Bob", "Ralf", "John", "John" ), Product = c ( "AAA", "AAA", "FFF", "FFF", "EEE", "EEE", "AAA", "FFF" ) ) # Insert RowIdx column, identifying the row index to assign each customer orders $ RowIdx <- match ( orders $ Customer, custs $ Customer ) # Insert ColIdx column, identifying the column index to assign each product orders $ ColIdx <- match ( orders $ Product, prods $ Product ) # Inspect orders # Customer Product RowIdx ColIdx # 1 Bob AAA 1 1 # 2 Bob AAA 1 1 # 3 Sue FFF 2 6 # 4 Sue FFF 2 6 # 5 Bob EEE 1 5 # 6 Ralf EEE 3 5 # 7 John AAA 4 1 # 8 John FFF 4 6