R/csv_xts_ts_converter.R

Defines functions csvToXts

Documented in csvToXts

#'Return an XTS Representation of a ChemTS csv File
#'
#'@param fileName A ChemTS csv file
#'@return An xts object containing the time series from the file provided as input. Assumes no header.
#'@import xts
#'@import zoo
#'@export

csvToXts <- function(fileName){
  stopifnot(is.character(fileName))

  aFrame = read.csv(file=fileName, header = FALSE, sep=",")
  aXTS = xts(aFrame[,2], order.by = as.POSIXlt(aFrame[,1]))
  return(aXTS)
}

#'Note: An xts object can easily be converted into a csv file using
#'write.zoo(xtsObject, file="<path>//<filename>.csv", sep=",")
joshmarsh/TSTestDataUtil documentation built on May 19, 2019, 8:54 p.m.