Problem with calculating tangency portfolio

Hi, and welcome!

Preliminarily, while the code blocks are helpful, they aren't quite a reproducible example, called a reprex, which is always helpful in attracting more and better answers.

In this case, however, it seems pretty clear that differences with the FALSE condition in tanportfolio() vs. w.tanportfolio <- tanportfolio(er, covmat, Rf , shorts=FALSE) is due to some difference in the datasets passed to the er argument, but I have no way of testing that.