Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
onlineforecast
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
packages
onlineforecast
Commits
378fe5c1
Commit
378fe5c1
authored
3 years ago
by
pbac
Browse files
Options
Downloads
Patches
Plain Diff
Fixed time zone subset issue
parent
2f982f4a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/data.list.R
+1
-1
1 addition, 1 deletion
R/data.list.R
R/in_range.R
+12
-7
12 additions, 7 deletions
R/in_range.R
with
13 additions
and
8 deletions
R/data.list.R
+
1
−
1
View file @
378fe5c1
...
...
@@ -120,7 +120,7 @@ subset.data.list <- function(x, subset = NA, nms = NA, kseq = NA, lagforecasts =
if
(
length
(
grep
(
"k[[:digit:]]+$"
,
names
(
X
)))
>
0
){
# If it holds forecasts, check that they are all there
if
(
!
all
(
pst
(
"k"
,
kseq
)
%in%
names
(
X
))
){
warning
(
pst
(
"The variable "
,
nms
[
i
],
" contain "
,
pst
(
names
(
X
),
collapse
=
","
),
" hence doesn't contain all k in kseq = "
,
pst
(
kseq
,
collapse
=
","
)))
warning
(
pst
(
"The variable "
,
nms
[
i
],
" contain
s
"
,
pst
(
names
(
X
),
collapse
=
","
),
" hence doesn't contain all k in kseq = "
,
pst
(
kseq
,
collapse
=
","
)))
}
}
}
...
...
This diff is collapsed.
Click to expand it.
R/in_range.R
+
12
−
7
View file @
378fe5c1
...
...
@@ -44,25 +44,30 @@
#' # since it's covering to "2010-12-25 23:00:00" to "2010-12-26 00:00:00"
#' D$t[in_range("2010-12-26", D$t, "2010-12-27")]
#'
#' # When characters are given, then they are translated to the time zone of the time vector
#' D <- subset(Dbuilding, c("2010-12-15", "2010-12-16"))
#' D$t <- ct(D$t, tz="CET")
#' D$t[in_range("2010-12-15 02:00", D$t, "2010-12-15 05:00")]
#'
#' @export
in_range
<-
function
(
tstart
,
time
,
tend
=
NA
,
timezone
=
NA
)
{
in_range
<-
function
(
tstart
,
time
,
tend
=
NA
)
{
if
(
is.na
(
tend
)){
tend
<-
time
[
length
(
time
)]
}
if
(
is.numeric
(
time
)){
return
(
tstart
<
time
&
time
<=
tend
)
}
else
{
# Use the time zone of the time when converting from character
tz
<-
attr
(
time
,
"tzone"
)
#
if
(
class
(
tstart
)[
1
]
==
"character"
){
tstart
<-
ct
(
tstart
)
tstart
<-
ct
(
tstart
,
tz
=
tz
)
}
if
(
class
(
tend
)[
1
]
==
"character"
){
tend
<-
ct
(
tend
)
tend
<-
ct
(
tend
,
tz
=
tz
)
}
if
(
is.na
(
timezone
)){
timezone
<-
attr
(
time
,
"tzone"
)
}
return
(
ct
(
tstart
,
tz
=
timezone
)
<
time
&
time
<=
ct
(
tend
,
tz
=
timezone
))
#timezone <- attr(time, "tzone")
return
(
tstart
<
time
&
time
<=
tend
)
}
}
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