R/parseIndex.R

parseIndex <- function (file)
{  
	empty <- data.frame(index = character(), description = character(),
		stringsAsFactors = FALSE)
	if (!file.exists(file)) return(empty)
	rl <- readLines(file) 
	if (!length(rl)) return(empty)
	lines <- (regexpr("^", rl) > 0)
	index <- gsub(" +.*$", "", rl[!lines])
	description <- gsub("^.*? +", "", rl[!lines])
	return(data.frame(index = index, description = description,
		stringsAsFactors = FALSE))
}

Try the svTools package in your browser

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

svTools documentation built on May 2, 2019, 3:21 a.m.