And you would be mistaken. The spear is superior in both contexts - with some caveats pertaining to particular circumstances. Aside from historical documents attesting to this fact, you can find any number of historical martial arts sparring videos online. One guy I personally like is Matt Easton of Scholagladiatoria.
https://www.youtube.com/watch?v=l2YgGY_OBx8
https://www.youtube.com/watch?v=vJcTD5qIZJ4
Ironically enough in contrast to your belief that the popularity of the spear was economic, many spear-based infantry, notably including the Greek hoplites, ALSO carried swords as side or secondary arms. (Stereotypically the Xiphos in the case of hoplites). Essentially, the superior reach of a spear allows earlier attacks, allows the user to threaten the opponent from a greater number of angles, and allows the user to more safely attack without exposing themselves. Of course the concept of military units that rely exclusively on one weapon is mostly fiction. There are circumstances in which a sword (as a secondary weapon or otherwise) might be a better choice. Including crowded tangles of melee combatants and confined interior spaces where there isn't sufficient space for a spear-user to attack or maintain distance. As far as duelling and/or self defense swords also had the advantages of being wearable without encumbering the hands during everyday life and of being more generally legal for civilians to carry. The pike, by the way, is unsuitable for personal combat - it's slow and unwieldy; although it allows (greater numbers of) successive ranks of combatants to focus arms on a given area on the battlefield. Something to keep in mind - the economics of warfare changed significantly throughout history. It was easily possible to outfit mass numbers of troops with swords and metal armor by the latter middle ages. There was even a comparatively brief period of time where mass-produced plate armor was cheap enough for large-scale infantry units. Spears and successor pole weapons maintained their popularity throughout this period.
Yeah, that fits my view (also a Matt Easton fan - I like how he doesn't let his preference for sabres distort his evaluations). Whether in a duel or en masse, spear alone normally beats sword alone, while spear & shield normally beats sword & shield. A sword might be superior at close quarters, but to survive to get to close quarters vs spears you need heavy armour & a good shield (& good tactical formation, eg the Romans).