Your code looks fine. I suspect you have a package conflict that has masked the select() function from dplyr. Try replacing select() with dplyr::select() and see if that works?
By the way, if this is a homework assignment, please read our homework policy:
Hi, I have a problem with the code below, it was working before but now 'usd' return '0' when I commented it it works again. May I have idea why 'usd' return '0' then 'total_return' is calculated "0"?
Please do not post screenshots, they are not very useful (and a bad thing to do here), instead, try to provide a proper REPRoducible EXample (reprex) illustrating your issue.