"~$800M on failed drugs for every ~$900M in revenue" Do you have a source for this? Looking at big Pharma the marketing budget is at least 2X the R&D budget so the numbers really look off from what you are posting?
Most of the actual R&D is done by smaller companies, and then the large companies (e.g. Pfizer) buy up the compounds in Phase ~2. They do have some of their own development, but it isn't the majority for most players. They'll primarily take drugs through Phase 3, then deal with synthesis, distribution, and marketing.
It is hard to look at a single company to see how the money is spent on failed drugs.