Say I have a data frame with one column of prices and multiple columns of dates. I'd like to calculate the mean prices of all observations by each date.
I thought about subsetting with split(), but I don't know how to apply it across multiple columns.
My example would be like this:
df
  Price  Date.1    Date.2      Date.3  
1  10   10/22/22   11/23/22    12/31/22     
2  18   8/1/22     10/22/22          
3  67   8/1/22     11/23/22       
4  23   10/11/22   10/22/22   
5  38   10/22/22   11/23/22    12/31/22    
6  41   6/7/22 
I would like to have mean prices by each date, so would be something like:
6/7.   mean of price at row 6
8/1    of row 2, 3
10/11. of row 4
10/22. of row 1, 2, 4, 5
11/23. of row 1, 3, 5
12/31. of row 1, 5
Thanks for any help!
 
     
     
    