Rewrite R script to R Markdown