I have a data frame with an observed variable and the date stamp [Var1, DD, MM, YYYY] that runs over thousands of rows. I need to fit a distribution [exponential or gamma] for each year's observed variable and get relevant parameters for each year.
In Matlab, it would just be
j=1
k=1
for i=1:(no_of_rows-1)
if year(i+1) = year(i)
temp_data_year(j) = Var1(i)
j=j+1
else [a,b]= gamfit(temp)
param(:,:,k) = [a,b]
k=k+1
endif
end
So I will get the parameters for every year in the data in variable param.
So is there something in R that can do this?
Thanks,