by-lapply function

Formula based version of lapply and sapply