Hi!

Can You please provide some advanced examples for readers about cast() function?

I am missing function for calculating trend of given x (slope of regression line for time series, which will be aggregated).

For example:

y = c(1.3, 1.6, 2.3, 4.5) - this vector will be aggregated - response variable

x = c(1,2,3,4) - just lenght(y) - explanatory variable

I am missing formula for regression slope (beta_1) with arbitrary length of y

some working examples from me:

M_mean<-cast(melt_data, ID_1+ID_2~variable, mean)

M_median<-cast(melt_data, ID_1+ID_2~variable, median)

M_std<-cast(melt_data, ID_1+ID_2~variable, sd)

M_range<-cast(melt_data, ID_1+ID_2~variable, function(x) max(x) - min(x))

M_skew<-cast(melt_data, ID_1+ID_2~variable, function(x) sum((x-mean(x))**3/sqrt(var(x))**3)/length(x))

M_kurtosis<-cast(melt_data, ID_1+ID_2~variable, function(x) sum((x-mean(x))**4/var(x)**2)/length(x) - 3)

Regards,

Jüri Kuusik

e-mail:

kuusik@neti.ee