Extract R code and comments from a given input string.
extract_r_code.Rd
This function takes an input string, detects R code and comments, and returns a character vector containing the R code and comments. The input string is split into lines based on newline characters, and each line is examined for R code and comment patterns. Only the lines that match either of these patterns are returned.
Arguments
- input_string
A character string containing R code and comments, mixed with other text. The string may contain multiple lines separated by newline characters.