The answer to the question is like most things with audio - it depends on the gear that's sending and receiving the data.
Whenever I have the option, I try both. I don't think I've ever never not preferred coaxial to optical in a comparison. My Bluesound Node 2i was far superior via coaxial into my Marantz SA-10.
Optical cables are cheap but there are more expensive coaxial cable options. My favorite coax is actually a Blue Jeans Cable coax that is reasonably priced. I have coaxial cables that are magnitudes greater in price and I prefer the Blue Jeans for $30 or whatever it was. I don't understand why but different coax cables altered the sound I heard.