Thanks Alex, we try at our best to create useful train travel website
And about your question - problem with Riga is that it has extremely bad rail connection with neighboring countries. So there is no train to Lithuania at all.
So you've got two choice, either to search for cheap AirBaltic/RyanAir tickets and get somewhere near Budapest (for instance Vienna). And from there you can easily continue your way to BP
Other option is to catch a bus to Vilnius/Kaunas or even Warsaw and continue from there by train.