Log returns of multiple securities for multiple time period in R
问题 I have dataset containing daily closing prices of 5413 companies from 2000 to 2014. I want to calculate daily log returns for the stocks as according to dates as log(Price today/Price yesterday). I illustrate the dataset as follows: Date A G L ABA ABB ABBEY 2000-1-3 NA NA NA NA 2000-1-4 79.5 325 NA 961 2000-1-5 79.5 322.5 NA 945 2000-1-6 79.5 327.5 NA 952 2000-1-7 NA 327.5 NA 941 2000-1-10 79.5 327.5 NA 946 2000-1-11 79.5 327.5 NA 888 How could calculate the the daily log returns and