#' Call failure plot
#'
#' Plot the call failures for each carrier
#'
#' @param call 'twilio' or 'm2m' for which call failures to plot
#' @return Returns standard fast-analysis structured list
#' @name callFailureMap
#' @family skeletonPlots
#' @export
callFailureMap <- function(call = "") {
if (call == "m2m") {
test_type_id <- "23"
save <- "m2m_failure_map"
} else if (call == "twilio") {
test_type_id <- "16"
save <- "twilio_failure_map"
} else {
test_type_id <- "c(16, 23)"
save <- "call_failure_map"
}
data <- pullCallStats()
process <- pullBaseMap()
process <- paste(process, "
## Create call stats friendly call status
callStats$call_type <- NA
callStats$call_type[callStats$is_drop & !is.na(callStats$is_drop)] <- 'Drop'
callStats$call_type[callStats$is_block & !is.na(callStats$is_block)] <- 'Block'
callStats$call_type[!callStats$is_block & !is.na(callStats$is_block) & !callStats$is_drop & !is.na(callStats$is_drop)] <- 'Success'
callStats <- callStats[callStats$call_type %in% c('Success', 'Drop', 'Block'), ]
## Set Order
callStats$call_type <- factor(callStats$call_type, levels = c('Success', 'Block', 'Drop'))
callStats <- callStats[order(callStats$call_type), ]
", sep = "\n")
plot <- sprintf("
#### %s Failure Map
df <- callStats[callStats$test_type_id %%in%% %s, ]
plt <- baseMap +
geom_point(data = df,
aes(x = lon,
y = lat,
fill = call_type,
shape = call_type,
size = call_type),
alpha = 0.8) +
scale_fill_manual(values = c('Success' = '#55BB55', 'Drop' = '#BB5555', 'Block' = '#BBBB55')) +
scale_shape_manual(values = c('Success' = 21, 'Drop' = 23, 'Block' = 24)) +
scale_size_manual(values = c('Success' = 3, 'Drop' = 8, 'Block' = 8)) +
theme_root() +
xlab('') +
ylab('') +
facet_wrap(~ carrier + test_type)
print(plt)
%s
",
call, test_type_id, saveLine(save))
output <- list(data = data,
process = process,
plot = plot,
save = save)
return(output)
}
#' @rdname callFailureMap
#' @export
m2mFailureMap <- function() callFailureMap(call = "m2m")
#' @rdname callFailureMap
#' @export
twilioFailureMap <- function() callFailureMap(call = "twilio")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.