Update 2013-28-post.R

# dapply - Originally Posted on www.EconometricsBySimulation.com

# Every so often I run into a situation when I find I need a function that seems to me that it should be very straightforward but because it seems so much so, it also becomes extremely difficult to find online.

# In this case, I am interested in a function that applies a function across and index of values and returns the results of that function as an equal length as the vector fed into the function.

# In the search for this specific function I found the base function tapply(vector, index, function) which does very close to what I want.

# However, tapply returns a vector of length equal to the number of factors in the index value.

# From the tapply function there might be a very easy way to get what I want.

# The reason I want this function is for data analysis purposes.  Often times we might want to see how well a variable that changes on the individual level (such as student education) might affect a variable that changes on the district level (per pupil spending).

# However, nothing occured to me.  So I programmed up an alternative function which has a few more bells and whistles.

# So hear it is.