зеркало из https://github.com/microsoft/wpa.git
chore: add alias for collab_ functions
This commit is contained in:
Родитель
a139ca5661
Коммит
74e0f4ff5c
|
@ -16,6 +16,11 @@ export(capacity_report)
|
|||
export(check_inputs)
|
||||
export(check_query)
|
||||
export(coaching_report)
|
||||
export(collab_area)
|
||||
export(collab_dist)
|
||||
export(collab_fizz)
|
||||
export(collab_line)
|
||||
export(collab_rank)
|
||||
export(collab_sum)
|
||||
export(collab_summary)
|
||||
export(collaboration_area)
|
||||
|
|
|
@ -137,3 +137,7 @@ collaboration_area <- function(data,
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#' @rdname collaboration_area
|
||||
#' @export
|
||||
collab_area <- collaboration_area
|
||||
|
|
|
@ -39,3 +39,7 @@ collaboration_dist <- function(data,
|
|||
|
||||
|
||||
}
|
||||
|
||||
#' @rdname collaboration_dist
|
||||
#' @export
|
||||
collab_dist <- collaboration_dist
|
||||
|
|
|
@ -33,3 +33,7 @@ collaboration_fizz <- function(data,
|
|||
return = return)
|
||||
|
||||
}
|
||||
|
||||
#' @rdname collaboration_fizz
|
||||
#' @export
|
||||
collab_fizz <- collaboration_fizz
|
||||
|
|
|
@ -64,3 +64,7 @@ collaboration_line <- function(data,
|
|||
stop("Invalid `return` value")
|
||||
}
|
||||
}
|
||||
|
||||
#' @rdname collaboration_line
|
||||
#' @export
|
||||
collab_line <- collaboration_line
|
||||
|
|
|
@ -27,10 +27,15 @@ collaboration_rank <- function(data,
|
|||
mingroup = 5,
|
||||
return = "table"){
|
||||
|
||||
data %>%
|
||||
create_rank(metric="Collaboration_hours",
|
||||
hrvar = hrvar,
|
||||
mingroup = mingroup,
|
||||
return = return)
|
||||
|
||||
create_rank(data,
|
||||
metric="Collaboration_hours",
|
||||
hrvar = hrvar,
|
||||
mingroup = mingroup,
|
||||
return = return)
|
||||
|
||||
}
|
||||
|
||||
#' @rdname collaboration_rank
|
||||
#' @export
|
||||
collab_rank <- collaboration_rank
|
||||
|
|
|
@ -77,7 +77,7 @@ collaboration_summary <- collaboration_sum
|
|||
|
||||
#' @rdname collaboration_sum
|
||||
#' @export
|
||||
collab_summary <-collaboration_sum
|
||||
collab_summary <- collaboration_sum
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,17 +13,7 @@
|
|||
#' @details
|
||||
#' Uses the metric `Collaboration_hours`.
|
||||
#'
|
||||
#' @param data A Standard Query dataset in the form of a data frame.
|
||||
#' @param hrvar HR Variable by which to split metrics, defaults to "Organization"
|
||||
#' but accepts any character vector, e.g. "LevelDesignation"
|
||||
#' @param mingroup Numeric value setting the privacy threshold / minimum group size. Defaults to 5.
|
||||
#' @param return Character vector specifying what to return, defaults to "plot".
|
||||
#' Valid inputs are "plot" and "table".
|
||||
#'
|
||||
#' @import dplyr
|
||||
#' @import ggplot2
|
||||
#' @import reshape2
|
||||
#' @import scales
|
||||
#' @inheritParams create_trend
|
||||
#'
|
||||
#' @family Collaboration
|
||||
#'
|
||||
|
@ -35,71 +25,13 @@
|
|||
|
||||
collaboration_trend <- function(data,
|
||||
hrvar = "Organization",
|
||||
mingroup=5,
|
||||
mingroup = 5,
|
||||
return = "plot"){
|
||||
|
||||
## Check inputs
|
||||
required_variables <- c("Date",
|
||||
"Collaboration_hours",
|
||||
"PersonId")
|
||||
|
||||
## Error message if variables are not present
|
||||
## Nothing happens if all present
|
||||
data %>%
|
||||
check_inputs(requirements = required_variables)
|
||||
|
||||
myTable <-
|
||||
data %>%
|
||||
mutate(Date = as.Date(Date, "%m/%d/%Y")) %>%
|
||||
rename(group = !!sym(hrvar)) %>% # Rename HRvar to `group`
|
||||
select(PersonId, Date, group, Collaboration_hours) %>%
|
||||
group_by(group) %>%
|
||||
mutate(Employee_Count = n_distinct(PersonId)) %>%
|
||||
filter(Employee_Count >= mingroup) # Keep only groups above privacy threshold
|
||||
|
||||
myTable <-
|
||||
myTable %>%
|
||||
group_by(Date, group) %>%
|
||||
summarize(Employee_Count = mean(Employee_Count),
|
||||
Collaboration_hours = mean(Collaboration_hours))
|
||||
|
||||
myTable_plot <- myTable %>% select(Date, group, Collaboration_hours)
|
||||
|
||||
myTable_return <- myTable_plot %>% spread(Date, Collaboration_hours)
|
||||
|
||||
plot_object <-
|
||||
myTable_plot %>%
|
||||
ggplot(aes(x = Date , y = group , fill = Collaboration_hours)) +
|
||||
geom_tile(height=.5) +
|
||||
scale_fill_gradient(name="Hours", low = "#FFFFFF", high = "#fe7f4f") +
|
||||
theme_classic() +
|
||||
theme(axis.text=element_text(size=12),
|
||||
plot.title = element_text(color="grey40", face="bold", size=18),
|
||||
plot.subtitle = element_text(size=14),
|
||||
legend.position = "right",
|
||||
legend.justification = "right",
|
||||
legend.title=element_text(size=14),
|
||||
legend.text=element_text(size=14)) +
|
||||
labs(title = "Collaboration Hours",
|
||||
subtitle = paste("Total meeting and email time by", tolower(hrvar))) +
|
||||
xlab("Date") +
|
||||
ylab(hrvar) +
|
||||
labs(caption = extract_date_range(data, return = "text"))
|
||||
|
||||
if(return == "table"){
|
||||
|
||||
myTable_return %>%
|
||||
as_tibble() %>%
|
||||
return()
|
||||
|
||||
} else if(return == "plot"){
|
||||
|
||||
return(plot_object)
|
||||
|
||||
} else {
|
||||
|
||||
stop("Please enter a valid input for `return`.")
|
||||
|
||||
}
|
||||
create_trend(data,
|
||||
metric = "Collaboration_hours",
|
||||
hrvar = hrvar,
|
||||
mingroup = 5,
|
||||
return = return)
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
% Please edit documentation in R/collaboration_area.R
|
||||
\name{collaboration_area}
|
||||
\alias{collaboration_area}
|
||||
\alias{collab_area}
|
||||
\title{Collaboration - Stacked Area Plot}
|
||||
\usage{
|
||||
collaboration_area(data, hrvar = "Organization", mingroup = 5, return = "plot")
|
||||
|
||||
collab_area(data, hrvar = "Organization", mingroup = 5, return = "plot")
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{A Standard Query dataset in the form of a data frame.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
% Please edit documentation in R/collaboration_dist.R, R/create_dist.R
|
||||
\name{collaboration_dist}
|
||||
\alias{collaboration_dist}
|
||||
\alias{collab_dist}
|
||||
\alias{collaboration_distribution}
|
||||
\title{Distribution of Collaboration Hours as a 100\% stacked bar}
|
||||
\usage{
|
||||
|
@ -13,6 +14,14 @@ collaboration_dist(
|
|||
cut = c(15, 20, 25)
|
||||
)
|
||||
|
||||
collab_dist(
|
||||
data,
|
||||
hrvar = "Organization",
|
||||
mingroup = 5,
|
||||
return = "plot",
|
||||
cut = c(15, 20, 25)
|
||||
)
|
||||
|
||||
collaboration_distribution(
|
||||
data,
|
||||
hrvar = "Organization",
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
% Please edit documentation in R/collaboration_fizz.R
|
||||
\name{collaboration_fizz}
|
||||
\alias{collaboration_fizz}
|
||||
\alias{collab_fizz}
|
||||
\title{Distribution of Collaboration Hours (Fizzy Drink plot)}
|
||||
\usage{
|
||||
collaboration_fizz(data, hrvar = "Organization", mingroup = 5, return = "plot")
|
||||
|
||||
collab_fizz(data, hrvar = "Organization", mingroup = 5, return = "plot")
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{A Standard Person Query dataset in the form of a data frame.}
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
% Please edit documentation in R/collaboration_line.R
|
||||
\name{collaboration_line}
|
||||
\alias{collaboration_line}
|
||||
\alias{collab_line}
|
||||
\title{Collaboration Time Trend - Line Chart}
|
||||
\usage{
|
||||
collaboration_line(data, hrvar = "Organization", mingroup = 5, return = "plot")
|
||||
|
||||
collab_line(data, hrvar = "Organization", mingroup = 5, return = "plot")
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{A Standard Query dataset in the form of a data frame.}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
% Please edit documentation in R/collaboration_rank.R
|
||||
\name{collaboration_rank}
|
||||
\alias{collaboration_rank}
|
||||
\alias{collab_rank}
|
||||
\title{Collaboration Ranking}
|
||||
\usage{
|
||||
collaboration_rank(
|
||||
|
@ -10,6 +11,8 @@ collaboration_rank(
|
|||
mingroup = 5,
|
||||
return = "table"
|
||||
)
|
||||
|
||||
collab_rank(data, hrvar = extract_hr(data), mingroup = 5, return = "table")
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{A Standard Person Query dataset in the form of a data frame.}
|
||||
|
|
Загрузка…
Ссылка в новой задаче