R/read.ba.sample.R

Defines functions read.ba.sample

Documented in read.ba.sample

read.ba.sample<- function(CSV) {

# Find start and stop position of the data in the file
CSV.file <- file(CSV, encoding="ISO-8859-1")
CSV.lines <- readLines(CSV.file)
close(CSV.file)
timevalue.start  <- grep('Time,Value', CSV.lines)
timevalue.length <- grep("^ $", CSV.lines[timevalue.start:length(CSV.lines)])[1] - 2

# Load the data and return a data frame.
timevalue <-  scan(CSV, skip=timevalue.start, nlines=timevalue.length, sep=',')
dim(timevalue) <- c(2, timevalue.length)
timevalue <- data.frame(t(timevalue))
colnames(timevalue) <- c('Time', 'Value')

return(timevalue)

}
charles-plessy/molaR documentation built on April 15, 2021, 1:21 a.m.