Skip to content
Snippets Groups Projects
Commit e62739c0 authored by jml's avatar jml
Browse files

add a sub_period funciton

parent 9a294e20
No related branches found
No related tags found
No related merge requests found
......@@ -107,3 +107,38 @@ get_name_date_col <- function(precision){
res <-c("WDAY",res)
return(res)
}
#' sub_period
#' sub_period
#' @param tbl_fts tbl friendlyts
#' @param fromDate fromDate
#' @param toDate toDate
#' @param timeResolution timeResolution
#' @param tzone tzone
#' @keywords friendlyts
#' @export
#' @examples
#' \dontrun{
#' sub_period()
#' }
sub_period <- function(tbl_fts,fromDate,toDate,timeResolution,tzone="UTC"){
tmp <- dfts(tbl_fts=tbl_fts,timeResolution=timeResolution,tzone=tzone)
from = timemanip::YYYYmmddHHMMSS2_chr(as.character(fromDate),tzone=tzone)
to = timemanip::YYYYmmddHHMMSS2_chr(as.character(toDate),tzone=tzone)
indice <- which((tmp$date >= from) & (tmp$date <= to))
if (!is.null(indice)) {
res <- as_tbl_friendlyts(df=tmp[indice,],precision=timeResolution,date_col="date",date_type="posixlt",CHECKNAS=FALSE)
} else stop("indice is NULL")
return(res)
}
setnames <- function (object = name, name) {
names(object) <- name
return(object)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{sub_period}
\alias{sub_period}
\title{sub_period
sub_period}
\usage{
sub_period(tbl_fts, fromDate, toDate, timeResolution, tzone = "UTC")
}
\arguments{
\item{tbl_fts}{tbl friendlyts}
\item{fromDate}{fromDate}
\item{toDate}{toDate}
\item{timeResolution}{timeResolution}
\item{tzone}{tzone}
}
\description{
sub_period
sub_period
}
\examples{
\dontrun{
sub_period()
}
}
\keyword{friendlyts}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment