# How to form Decile Portfolios based on Liquidity measure with missing data in R

I have a dataframe with over 4000 companies data (as column) and have calculted their daily Quoted spread measure ( measures liquidity for each stock) for 15 years. And then from the daily have estimated the monthly average Quoted spread for each company( for 180 months). Now, I want is to form equally wieghted decile portfolios of these companies specifically at the beginning of each year in my sample period meaning I want to form 10 portfolios at the beginning of each year based on the liquidity measured. Below I illustrate small portion of my data

Month   A        B      C   D       E   F        G      H   I   J
Jan-00  0.05    0.02    NA  0.00    NA  0.04    0.04    NA  NA  0.03
Feb-00  0.07    0.02    NA  0.01    NA  0.04    0.08    NA  NA  0.02
Mar-00  0.09    0.02    NA  0.00    NA  0.04    0.07    NA  NA  0.03
Apr-00  0.11    0.02    NA  0.00    NA  0.03    0.08    NA  NA  0.03
May-00  0.14    0.02    NA  0.00    NA  0.03    0.06    NA  NA  0.02
Jun-00  0.15    0.01    NA  0.01    NA  0.04    0.05    NA  NA  0.02
Jul-00  0.10    0.02    NA  0.01    NA  0.03    0.05    NA  NA  0.04
Aug-00  0.11    0.02    NA  0.00    NA  0.03    0.03    NA  NA  0.03
Sep-00  0.08    0.02    NA  0.01    NA  0.04    0.03    NA  NA  0.02
Oct-00  0.11    0.02    NA  0.01    NA  0.03    0.04    NA  NA  0.02
Nov-00  0.17    0.02    NA  0.01    NA  0.04    0.04    NA  0.01 0.05
Dec-00  0.18    0.02    NA  0.01    NA  0.04    0.03    NA  0.01 0.01
Jan-01  0.25    0.02    NA  0.00    NA  0.04    0.03    NA  0.01 0.01
Feb-01  0.23    0.02    NA  0.01    NA  0.04    0.03    NA  0.01 0.01
Mar-01  0.13    0.03    NA  0.01    NA  0.04    0.03    NA  0.01 0.01
Apr-01  0.19    0.03    NA  0.01    NA  0.06    0.03    NA  0.01    NA
May-01  0.15    0.03    NA  0.01    NA  0.04    0.03    NA  0.01    NA
Jun-01  0.33    0.03    NA  0.01    NA  0.05    0.03    NA  0.01    NA
Jul-01  0.24    0.04    NA  0.00    NA  0.05    0.03    NA  0.00    NA
Aug-01  0.29    0.04    NA  0.00    NA  0.03    0.02    NA  0.00    NA
Sep-01  0.25    0.04    NA  0.00    NA  0.05    0.03    NA  0.01    NA
Oct-01  0.20    0.05    NA  0.00    NA  0.05    0.02    NA  0.01    NA
Nov-01  0.24    0.03    NA  0.01    NA  0.04    0.02    NA  0.01    NA
Dec-01  0.33    0.02    NA  0.00    NA  0.04    0.03    NA  0.01    NA


It is hard to provide a reproduciable data.So,I want is that to form 10 portfolios at the beginning of year 2001 based the 2000. And then form decile portfolio at the beginning of 2002 based on 2001. I want to sort the stocks based on their liquidity. I would really appreciate your help even if you give me an idea how to go about this portfolio formation.