I have a data frame with color, quality and price and I want to compare how the color changes perception of quality.
I need to get a table with the mean of the prices for every color and quality combination.
I am currently trying with aggregate but I can't seem to find the proper combination.
aggregate(price ~ color, list(Quality = D$quality), data=D, FUN=mean);
Input:
Quality   | Color | Price
Good      | Red   | 4500
Excellent | Green | 5000
Bad       | Blue  | 420
......
Output: mean prices table
.         Red .    Blue . Green
Excellent . 4520 .  4200 .  3500 
Good .      3950 .  3722 .  3021
Bad .       1523 .  1232 .  900
 
    