add code from dr nitai's sweave presentation