import re


def extract_r(rmd_content):
    """Extract the actual R code from the given Rmd script"""
    return "\n".join(re.findall(r"^```\{r[ \}].*?$(.+?)^```", rmd_content, flags=re.MULTILINE|re.DOTALL))