extract_r_code function

Extract R code and comments from a given input string.