Hi Maciej, and welcome to community.rstudio.com!
I'm glad you were able to get helpful answers on StackOverflow. For future reference, if you plan to crosspost with another forum, please include the link to your other posting when submitting your question to this community. This will help prevent users from spending time answering a question that may already have been answered elsewhere. For more information, please check out our crossposting FAQ.