R/get_comments_from_lines.R

Defines functions get_comments_from_lines

Documented in get_comments_from_lines

#' Get comments at the beginning of a vector of strings
#' 
#' @param lines Vector of strings, typically obtained from using \code{scan} with \code{sep='\n'}.
#' @return Vector of strings with the commented lines.
#' @export
get_comments_from_lines <- function(lines)
{
  i <- 0
  comments <- NULL
  while(i==0) 
  {
    ifelse(substr(lines[1], 1,1)=='#', comments <- append(comments,lines[1]), i<-1)   
    lines <- lines[-1]
  }
  return(comments)
}
rogiersbart/rtoolz documentation built on Aug. 20, 2020, 2:48 p.m.