#' Import of Hobo RAW data in R
#'
#' Create a data.frame containing a column with dates of measurements (format YYYY-MM-DD HH:MM:SS UTC)
#' and a second one with measurements.
#'
#' @usage
#' time_rawshape(file,Pcol,Dcol,tz,order,sep,skip)
#'
#' @param file character string containing the path to the RAW csv file
#' @param Pcol integer indicating the column number wich contains the Parameter data
#' @param Dcol integer indicating the column number which contains the Dates of measurements
#' @param tz character string (see OlsonNames()).
#' @param order character string setting date format.
#' @param sep character string indicating what is the separator in csv file. Default is ",".
#' @param skip number of lines to skip before to read data.
#'
#' @return a data.frame containing a column with date of measurements in a
#' "YYYY-MM-DD HH:MM:SS UTC" format and the hourly parameter's value for each date.
#'
#' @example
#' data<-time_rawshape("datahobo1.csv",Pcol=5,Dcol=2,tz="Etc/GMT+2",sep=",")
#' str(data)
#'
#' @author Remy Moine <remymoine95@gmail.com>
#' @export
time_rawshape<-function(file,Pcol,Dcol,tz,order,sep,skip){
tmp<-utils::read.table(file=file,sep=sep,header=F,skip=skip,stringsAsFactors=F)
tmp2<-lubridate::parse_date_time(as.character(as.vector(tmp[,Dcol])),orders= order,tz=tz)
tmp3<-lubridate::with_tz(tmp2,tzone="UTC")
sel<-which(is.na(tmp[,Pcol])==T)
if(length(sel)==0){
objet<-data.frame(Dates=tmp3,Parameter=as.numeric(as.vector(tmp[,Pcol])))} else {
objet<-data.frame(Dates=tmp3[-sel],Parameter=as.numeric(as.vector(tmp[-sel,Pcol])))}
objet
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.