Sorry but I am not a student, at least not since 2007. However I am performing grunt work for a someone with a Ph.D. so it does remind me of the student days. I just have a pay check instead of student loans.
I assume Q*D*R instead of Q %*% D %*% R is the mistake. At least you didn't say I blundered the theory.