We will essentially do three major things in this section. First, we calculate sector averages for fields that we can use in our relative valuation efforts. Then, we do the same at the industry level. Finally, we compare the stocks' statistics to the averages to arrive at an index value for each stock that indicates whether it might be undervalued. The following steps will guide you:
- In order to calculate averages in multiple columns in R, we first need to melt the data. This will make every column after Sector a row and then display its value, essentially making the data long instead of wide. Take a look at the following screenshot for the different steps in this recipe to better understand how the data changes shape. It goes ...