代わりに: accepting one thing in return for another
Read tradeoffs and substitutions, and distinguish them from the simpler contrast expressed by けど.
Trading an advantage for a disadvantage
この部屋は少し狭い代わりに、家賃が安いです。 means that the room is a little small, but the rent is low in return. It evaluates the two features as a tradeoff: accepting limited space in exchange for lower rent.
安い代わりに駅から遠いです means that it is inexpensive but far from the station in return. The first clause need not be the disadvantage and the second the advantage; the key is the tradeoff between the two.
Substituting another action or person
今日は外食する代わりに、家で料理します。 means that the speaker will cook at home instead of eating out today. It replaces one action with another, rather than listing two actions that will both happen.
With a noun, use の, as in 私の代わりに. 私の代わりに弟が行きます。 means that the speaker's younger brother will go in their place. It need not mean that his going compensates for a fault in the speaker.
A more specific relation than contrast alone
狭いけど、家賃が安いです。 can also contrast limited space with low rent. 代わりに, however, more explicitly presents accepting one feature in return for another benefit.
Check whether the relationship is compensation or substitution in each sentence. With 狭い代わりに安い, both states coexist; with 外食する代わりに料理する, one action takes the place of another.
Does 今日は外食する代わりに、家で料理します。 mean both eating out and cooking at home?
Show the answer and why
No. It means choosing to cook at home instead of eating out. Here 代わりに expresses substitution between actions rather than coexisting advantages and disadvantages.

