Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
friendlyts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RfriendlyTS
friendlyts
Commits
e62739c0
Commit
e62739c0
authored
6 years ago
by
jml
Browse files
Options
Downloads
Patches
Plain Diff
add a sub_period funciton
parent
9a294e20
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/utils.R
+35
-0
35 additions, 0 deletions
R/utils.R
man/sub_period.Rd
+30
-0
30 additions, 0 deletions
man/sub_period.Rd
with
65 additions
and
0 deletions
R/utils.R
+
35
−
0
View file @
e62739c0
...
...
@@ -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
)
}
This diff is collapsed.
Click to expand it.
man/sub_period.Rd
0 → 100644
+
30
−
0
View file @
e62739c0
% 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}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment