I often work with RMarkdown in RStudio Cloud, and sometimes find memory problems. So, I've just found a code line (first shared by Yihui Xie), which solved the issue, and I'd like to share it here, too. The line is to be run on the console.
stack_size <- getOption("pandoc.stack.size", default = "512m")