Is Rio actually safe?

I have been to most big cities in Asia and Europe but haven’t explored much of South America outside of a trip to Peru in college.

I keep meaning to go visit Rio and elsewhere in Brazil but I have heard so many horror stories of tourists getting their stuff stolen at gunpoint and I feel like I look like an easy tourist target and fear the chance of that happening to me is high, especially if I were to go out to bars or clubs.

Is this an unfounded worry? I think maybe if I were in a planned tour with a large group and a local guide it might be different.