I can partially answer this!
When creating the chunk that contains str_to_upper, you can change the chunk options to modify the output decoration. To remove the ##, use
``` {r, comment=""}
str_to_upper
If you want this as a global setting (so all chunks in document will lack the ## decoration), modify the setup chunk at the top:
```{r setup, include=FALSE}
knitr::opts_chunk$set(comment="")
I have no idea how to help with removing the bytecode or environment output, but here is where chunk options are further described?