Yes, or if the flight times work then even a day trip might be possible. However hotels in Riga are probably cheaper than Stockholm for the same quality of hotel.
I did Vilnius as a day trip from Stockholm, and Riga as a day trip from Tallinn (!!) Would have liked to spend more than 4 hours in Riga but unfortunately that was the only workable schedule (I had a work-related activity lasting the first hour then 3 hours of wandering).