The medium companies generally have a single true line of business and are focused on tuning & turning that crank, turning $3M/yr to $10-100M/yr. Doing something else makes you a trouble maker, and budgets are watched.
The bigger companies will have $100M-100B/yr revenue, so they'll do pretty insane engineering on the old product lines ("let's reimplement PHP with a modern VM!"), and take moonshots to enter new markets big enough to make a dent ("Let's give internet to everyone in Africa.") So both quality of life can be better and the projects can be more interesting and career defining.
So yeah, I'd go to bigco, or if a medco, one with enough ridiculous growth/funding to do insane things. But not a lot of years of your life that startups are easily doable, so I switched from R&D to startups, and can always go back later :)