I have two data frames: one contains the food items consumed by patients with quantity (column for patients and each food item in a column) and the second is the value of (Flavonoids, phenolic acids, stilbenes, lignans, and other phenols) in 100g of the food item, also each class of phenols in a column. I wrote a code that calculates the total value of each phenol class, it is a multiplication of the quantity consumed of each food item by the value of the phenol class in 100g of the food item.
Now I want to create a new data frame that gathers the patient column with columns for each phenol class containing the results of the multiplication. The goal is to have final numbers on how much did the patient consumed flavonoids, phenolic acids, Stilbenes, lignans, and other phenols. How should I express this on Rstudio?