-
Notifications
You must be signed in to change notification settings - Fork 3
/
ts_alos_plt.Rd
73 lines (65 loc) · 1.77 KB
/
ts_alos_plt.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/time_series_plots.R
\name{ts_alos_plt}
\alias{ts_alos_plt}
\title{Plot ALOS - Average Length of Stay}
\usage{
ts_alos_plt(.data, .date_col, .value_col, .by_grouping, .interactive)
}
\arguments{
\item{.data}{The time series data you need to pass}
\item{.date_col}{The date column}
\item{.value_col}{The value column}
\item{.by_grouping}{How you want the data summarized - "sec", "min", "hour",
"day", "week", "month", "quarter" or "year"}
\item{.interactive}{TRUE or FALSE. TRUE returns a \code{plotly} plot and FALSE
returns a static \code{ggplot2} plot}
}
\value{
A timetk time series plot
}
\description{
Plot ALOS - Average Length of Stay
}
\details{
\itemize{
\item Expects a tibble with a date time column and a value column
\item Uses \code{timetk} for underlying sumarization and plot
\item If .by_grouping is missing it will default to "day"
\item A static ggplot2 object is return if the .interactive function is FALSE
otherwise a \code{plotly} plot is returned.
}
}
\examples{
library(healthyR)
library(healthyR.data)
library(timetk)
library(dplyr)
library(purrr)
# Make A Series of Dates ----
data_tbl <- healthyR_data
df_tbl <- data_tbl \%>\%
filter(ip_op_flag == "I") \%>\%
select(visit_end_date_time, length_of_stay) \%>\%
summarise_by_time(
.date_var = visit_end_date_time
, .by = "day"
, visits = mean(length_of_stay, na.rm = TRUE)
) \%>\%
filter_by_time(
.date_var = visit_end_date_time
, .start_date = "2012"
, .end_date = "2019"
) \%>\%
set_names("Date","Values")
ts_alos_plt(
.data = df_tbl
, .date_col = Date
, .value_col = Values
, .by = "month"
, .interactive = FALSE
)
}
\author{
Steven P. Sanderson II, MPH
}