R/extract_comments.R

Defines functions extract_comments

extract_comments <- function(raw_lines){
  comment_lines <- grep('!',
                        iconv(raw_lines, sub = "?"),
                        value = TRUE)
  comments <- gsub(" +$", # remove trailing spaces
                   "",
                   # extract only comments prefaced with !
                   regmatches(comment_lines,
                              regexpr("(?<=!).*",
                                      comment_lines,
                                      perl = TRUE)))
  return(comments)
}

Try the DSSAT package in your browser

Any scripts or data that you put into this service are public.

DSSAT documentation built on Nov. 9, 2023, 1:08 a.m.