What do you do when someone is angry with you and yells at you? Most people react with anger of their own or by defending themselves. Both reactions are wrong! It is true that the angry person is afraid of something, because anger is a mask for fear, but that is their lesson and not yours! Your lesson is to work out why you are having the feelings that you are having. You are reacting because of those feelings and not because of the other person's antagonism. This person was sent into your life to teach you something and your part in the drama is to work out what you have to learn from it.
Do you get angry in return? Why? What hidden fears do you have? Do you feel sad? If so, what sadness do you have buried that you have avoided dealing with? Do you feel that you have to defend yourself? Why? Because there is a sense of insecurity within you that you haven't dealt with.
For many people, they react because they can't handle the concept that there is someone who doesn't like them. There will always be someone who doesn't like you, no matter how kind and compassionate you are. That is just a fact of life and you have to accept it and in fact what other people think of you is none of your business. You have no idea what their life is about. You may bear a physical resemblance to someone who has greatly wronged them; you can't help that. There are many possible scenarios.
The truth is that angry people hurt and they haven't as yet worked out how to heal that hurt. When you realise that, you may find that your own feelings will change very naturally into compassion.
When someone is angry or nasty don't lower yourself to their level by reacting in kind. Take a moment to think before reacting. Your soul has attracted this person into your life to force you to examine your feelings. If you don't deal with it now, it will happen again and quite possibly in a more dramatic way. Even though it may cause you some discomfit, dealing with it now is much easier than you probably think and will prevent future occurrences.
Of course if you have done anything wrong that can possibly justify the other person's behaviour, then apologise first but don't feel you have to justify your wrong deed; a genuine heartfelt apology is all the you need to give, e.g. "I'm sorry! I was wrong to do/say that." In some cases this is enough to calm the other person down. But if not, then it becomes their problem and not yours.
Once you can face an angry person without reacting then that is good. Then you can help them to see why they are angry. You could ask them, "What are you afraid of?" Of course they may not be ready to accept help just yet but even so you might be planting a seed that they will remember later on.
There are times when a person becomes physically violent, in which case it is wise to retreat, at least until they calm down. But even this you would have attracted for some reason and so you must still deal with your own feelings even if there is nothing you can do to help them at this stage.