How to create a new data frame out of a combination between previous data and code results?

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?

Hi, can you provide a reproducible example with the code you've tried?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.