SQL made relational programming possible, when computer were too slow to do declarative programming.
The modern aproach would be something more highlevel/declarative like Datalog, but given the context SQL made a good tradeoff in terms of programmer control and declarativity.
R is ugly because it encourages users to use it wrong. For loops are slow as a snail, but are what everybody uses and teaches, while the proper/fast way to wrangle data, with higher order functions like map, is hidden behind idiosyncratic names and obscure APIs.
Even the creator of R considered making it a language instead of the scheme library that it started iut as, as a mistake.