As mentioned by @Joseph, Paul is quoting Psalm 4:
4Be angry, and do not sin;
ponder in your own hearts on your beds, and be silent. ESV
When quoting from the Old Testament, New Testament authors assume the context of the quotation is understood or will be examined1, so we need to look at more of Psalm 4 to understand Paul's meaning.
The ESV offers 'agitated' as a possible alternative translation of 'angry', and this kind of reading is supported by the rest of the text in the very same verse. Psalm 4 includes Hebrew parallelism2, of which verse 4 is one example:
This "parallelism" is a phenomenon noticed in the portions of the Old Testament that are at the same time marked frequently by the so-called dialectus poetica; it consists in a remarkable correspondence in the ideas expressed in two successive verses3
Though in this case parallelism is contained within a single verse, and "Be angry, and do not sin" corresponds to "ponder in your own hearts on your beds, and be silent".
Specifically, the parallel second part makes it clear that the first part is not in any way to be taken as an instruction to be angry, rather the emphasis is on what you do with your agitation/anger: quietly meditate on it rather than "express it". If Psalm 4 understood properly does not contain an injunction to 'be angry', it seems unlikely that that is Paul's intent either.
1 for example see the last verse of Psalm 22; the first verse is quoted by Jesus on the cross
2 primarily a communication tool in my view, and only secondarily a 'poetic' device: it significantly reduces ambiguity
3 emphasis mine