Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
rdiagnosis
basicr
Commits
ad0ae70b
Commit
ad0ae70b
authored
Jan 31, 2019
by
Jean-Marie Lepioufle
Browse files
box-whisker timeserie plot with observations
parent
ad6155f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/plot_boxwhisk_ts.R
0 → 100644
View file @
ad0ae70b
#' plot_boxwhisk_ts
#' plot_boxwhisk_ts
#' @param x object of class tbl_friendlyts
#' @param fromDate fromDate
#' @param toDate toDate
#' @param timeResolution timeResolution
#' @param tzone tzone
#' @param path path
#' @param name name
#' @param width_mm width_mm
#' @param height_mm height_mm
#' @param y_name name on the y-axis
#' @param DESKTOP boolean
#' @keywords friendlyts
#' @export
#' @examples
#' \dontrun{
#' plot_boxwhisk_ts()
#' }
plot_boxwhisk_ts
<-
function
(
x
,
fromDate
=
NULL
,
toDate
=
NULL
,
timeResolution
=
NULL
,
tzone
=
"UTC"
,
path
=
tempdir
(),
name
=
NULL
,
width_mm
=
200
,
height_mm
=
200
,
y_name
=
"Y-axis"
,
DESKTOP
=
TRUE
){
# sub-period
if
(
!
is.null
(
fromDate
)
&&
!
is.null
(
toDate
)
&&
!
is.null
(
timeResolution
))
{
df
<-
friendlyts
::
sub_period
(
tbl_fts
=
x
,
fromDate
=
fromDate
,
toDate
=
toDate
,
timeResolution
=
timeResolution
,
tzone
=
tzone
)
}
else
df
<-
x
df
<-
friendlyts
::
dfts
(
tbl_fts
=
df
,
timeResolution
=
timeResolution
,
tzone
=
tzone
)
df
[[
"date"
]]
<-
as.POSIXct
(
df
[[
"date"
]])
#start plot
if
(
!
(
DESKTOP
))
{
if
(
is.null
(
name
))
{
filename
<-
normalizePath
(
file.path
(
path
,
paste0
(
"boxwhisk_ts.tiff"
)),
mustWork
=
FALSE
)
}
else
filename
<-
normalizePath
(
file.path
(
path
,
paste0
(
"boxwhisk_ts_"
,
name
,
".tiff"
)),
mustWork
=
FALSE
)
grDevices
::
tiff
(
filename
=
filename
,
width
=
width_mm
,
height
=
height_mm
,
units
=
"mm"
,
pointsize
=
12
,
compression
=
"lzw"
,
bg
=
"transparent"
,
res
=
300
)
}
else
grDevices
::
dev.new
()
# plot
p
<-
ggplot2
::
ggplot
(
df
,
ggplot2
::
aes
(
x
=
date
))
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
ymin
=
q_0
,
lower
=
q_0_25
,
middle
=
q_0_5
,
upper
=
q_0_75
,
ymax
=
q_1
),
stat
=
"identity"
)
+
ggplot2
::
geom_line
(
ggplot2
::
aes
(
y
=
value
))
+
ggplot2
::
labs
(
x
=
"date"
,
y
=
y_name
)
print
(
p
)
if
(
!
(
DESKTOP
))
{
grDevices
::
dev.off
()
return
(
filename
)
}
else
{
return
(
TRUE
)
}
}
man/plot_boxwhisk_ts.Rd
0 → 100644
View file @
ad0ae70b
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_boxwhisk_ts.R
\name{plot_boxwhisk_ts}
\alias{plot_boxwhisk_ts}
\title{plot_boxwhisk_ts
plot_boxwhisk_ts}
\usage{
plot_boxwhisk_ts(x, fromDate = NULL, toDate = NULL,
timeResolution = NULL, tzone = "UTC", path = tempdir(),
name = NULL, width_mm = 200, height_mm = 200, y_name = "Y-axis",
DESKTOP = TRUE)
}
\arguments{
\item{x}{object of class tbl_friendlyts}
\item{fromDate}{fromDate}
\item{toDate}{toDate}
\item{timeResolution}{timeResolution}
\item{tzone}{tzone}
\item{path}{path}
\item{name}{name}
\item{width_mm}{width_mm}
\item{height_mm}{height_mm}
\item{y_name}{name on the y-axis}
\item{DESKTOP}{boolean}
}
\description{
plot_boxwhisk_ts
plot_boxwhisk_ts
}
\examples{
\dontrun{
plot_boxwhisk_ts()
}
}
\keyword{friendlyts}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment