'How to avoid collision of text in basic R?

text() puts text at specified coordinates. But some texts may overlap each other. How to wiggle the position of the text automatically so that they don't overlap?

The solution must be in basic R instead of using another R package as I will need to combine this with other basic R drawing commands to customize my drawing. Or the solution should provide a way to compute the wiggled coordinates. It should not directly draw the texts so that I can not combine it with my other drawing code in basic R.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source