[R] Dataframe Manipulation

Hemant Sain hemantsain55 at gmail.com
Wed Aug 30 08:27:55 CEST 2017


i want to do a market basket analysis and I’m trying to create a dataset
for that i have two tables,
one table contains daily transaction of products in which each row of table
shows item purchased by the customer,
The second table contains parent group under those products are fallen, for
example under fruit category there are several fruits like mango, banana,
apple etc.
i want to create a third table in which parent group are mentioned as
header which can be extracted from Table 2, and all the rows represent
transaction of products

with their names, and if there is no transaction for any parent category
then the cell supposed to fill as NA. please help me with R or C/c++ code(
R would be

preferred) here I’m attaching you all three tables for better reference i
have first two tables and i want to get a table like table 3

Tables are explained in the attached doc.

-- 
hemantsain.com
-------------- next part --------------
i want to do a market basket analysis and I’m trying to create a dataset for that i have two tables,
one table contains daily transaction of products in which each row of table shows item purchased by the customer,
The second table contains parent group under those products are fallen, for example under fruit category there are several fruits like mango, banana, apple etc.
i want to create a third table in which parent group are mentioned as header which can be extracted from Table 2, and all the rows represent transaction of products

with their names, and if there is no transaction for any parent category then the cell supposed to fill as NA. please help me with R or C/c++ code( R would be

preferred) here I’m attaching you all three tables for better reference i have first two tables and i want to get a table like table 3

Tables are explained in the attached doc

Table 1 :

          Item_1                       Item_2                Item_3     Item_4

 T1       1KG banana                   300ML milk            1kg sugar     NA
         
 T2       2 Large Corona Beer          2 pack Fries          NA            NA

 T3       2 Lux Soap                   1kg sugar             Na            Na





Table 2 :

        Toiletries     Fruits        Beverages             Snacks         Vegetables        Clothings                  Dairy Products   

        Soap           Banana        Corona Beer           King Burger      Pumpkin         Adidas Sport Tshirt XL     Milk

        Shampoo        Mango         Red Label Whisky      Potato Fries     Potato          Nike Shorts Black L        Butter

        Showergel      Oranges       grey Cocktail         cheese pizza     Tomato          Puma Jersy red M           Suger

        Lux Soap                     2 Large corona Beer                                                               Cheese

        Toothpest 



       
Table 3 :

        toiletries     Fruits                Beverages                     Snacks               Vegetables      Clothings                Dairy Products           

 
         NA            1kg Banana             NA                           NA or                NA             NA                        300ml milk,1kg Sugar 

         NA            NA                    2 Large corona Beer           2 pack Fries         NA             NA                        NA 

         2 Lux Soap    NA


More information about the R-help mailing list