In this chapter, the authors extend univariate portfolio analysis to bivariate sorts, which means they assign stocks to portfolios based on two characteristics. Bivariate sorts are regularly used in the academic asset pricing literature and are the basis for the Fama and French three factors. Having both variables, i.e., firm size lagged by one month and book-to-market lagged by six months, the developers merge these sorting variables to our returns using the sorting_date-column created for this purpose. Bivariate sorts create portfolios within a two-dimensional space spanned by two sorting variables. It is then possible to assess the return impact of either sorting variable by the return differential from a trading strategy that invests in the portfolios at either end of the respective variables spectrum. Write a function to compute the average characteristics for size and book-to-market across the 25 independently and dependently sorted portfolios.