Improved lda.R