I have a Panel Data set of different portfolios with prices and I want to track the performance of each over a period of 10 years. I already calculated the returns with:

```
returnfun <- function(x) c(NA, diff(x) / head(x, -1))
Portfolio10pd=returns=transform(Portfolio10pd, Returns = ave(prccm, GVKEY, FUN = returnfun))

```

When the GVKEY changes it produces 1 "Na" because there is no old price as reference. So I cleaned the NA return columns with

```
P10=subset(NaRV.omit(Portfolio10pd))

 head(P1, 10)
   GVKEY datadate  prccm       Returns
2      1 20100228 292.00 -0.0009921653
3      1 20100331 299.13  0.0244178082
4      1 20100430 317.82  0.0624811955
5      1 20100531 324.37  0.0206091498
6      1 20100630 302.92 -0.0661281869
7      1 20100731 334.17  0.1031625512
8      1 20100831 304.55 -0.0886375198
9      1 20100930 315.78  0.0368740765
10     1 20101031 375.84  0.1901957059

> tail(P1,10)
      GVKEY datadate prccm      Returns
20322   144 20200331 32.74 -0.238781679
20323   144 20200430 32.62 -0.003665241
20324   144 20200531 30.38 -0.068669528
20325   144 20200630 32.27  0.062211982
20326   144 20200731 30.71 -0.048342113
20327   144 20200831 28.02 -0.087593618
20328   144 20200930 26.58 -0.051391863
20329   144 20201031 24.75 -0.068848758
20330   144 20201130 31.20  0.260606061
20331   144 20201231 31.68  0.015384615

```

I have 144 Firms with monthly returns from February 2010 until December 2020. I would like to calculate the monthly returns of the equally weighted Portfolio to track the performance over time. I cannot use Return.portfolio() function of the performance analytics package because the returns are not in the right format. Has somebody a hint for me or a solution for that problem? I am new to R, so thank u very much!